>_ IzzyLab

Hands-on task

This task is step 12 of the course “cut, sort, uniq and friends”

Who is missing from the system

medium~5 min

The file /root/expected.txt contains a list of logins that must exist on the system (one per line). Find out which of them are not in /etc/passwd and write the missing logins to /root/missing.txt.

What you'll practise:
  • comm
  • -23
  • process substitution
  • sorting
  • cut

Topic breakdown

comm compares two pre-sorted files line by line and prints three columns: lines only in the first file, only in the second, and common lines. By suppressing the unneeded columns (-23 removes the 2nd and 3rd) you get the set difference "first minus second". Process substitution <(command) passes a command's output as a temporary file argument — this way comm gets sorted lists as input without intermediate files.

What's checked

  1. correct set of missing logins
  2. existing users not listed

What it looks like