The standard
grep
tool for searching files for text strings can be used to subtract all the lines in one file from another.
grep -F -x -v -f fileB fileA
This works by using each line in fileB as a pattern (-f fileB
) and treating it as a plain string to match (not a regular regex) (-F
). You force the match to happen on the whole line (-x
) and print out only the lines that don't match (-v
). Therefore you are printing out the lines in fileA that don't contain the same data as any line in fileB.