#!/bin/bash # This syntax is known as "process substitution". # It's only available in Bash, not in plain sh. comm -12 <(sort "${1}") <(sort "${2}") # Note: Think carefully whether to pipe the 'sort' outputs through # 'uniq'. It depends on how 'comm' behaves, which I haven't read up # on or thoroughly tested yet. # # Also, this whole program could be written more interestingly in a # real language to handle an arbitrary number of input files, and use # hashes to identify lines (thus avoiding the need for sorted input).