Scenario: every day we run a report that produce a csv file with some IDs and we want to check the differences that those two files might have, we need to check if there are missing IDs from the previous day CSV vs the current day CSV and vice versa.
The contents of the previous day file: previous.txt
The contents of the current day file: current.txt
- To find if there is an ID in the previous day file that does not exist in the current day file.
$ grep -Fxv -f current.txt previous.txt
2. To find If there is in ID in the current day file that does not exist in the previous day file.
$ grep -Fxv -f previous.txt current.txt
Explaination of the parameters:
-F:Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
-x: exact match
-v: invert match results
-f: files to grep