← All Exercises

Compare Two Lists with comm and Process Substitution

basicbash~20min

Background

Configuration drift checks compare desired membership with observed membership. comm needs sorted input, and process substitution keeps the comparison to one line per side.

Problem

Given an expected list and an actual list, print two sections: names present in expected but missing from actual, and names present in actual but absent from expected.

Input

Two readable text files with one entry per line; entries may be unsorted, duplicated, or blank.

Output

The header missing: followed by expected-only entries, then unexpected: followed by actual-only entries, each deduplicated and sorted.

Sample tests

Sample 1

Input: expected: alice, bob, carol; actual: bob, carol, dave
Expected: missing:
alice
unexpected:
dave

Sample 2

Input: identical lists containing alice and bob
Expected: missing:
unexpected:

Your solution

Learning objective

Use process substitution, comm column suppression, and shared normalization for reliable set comparisons.