Reverse diff

Here is an example how to use grep a “reverse diff” to find different lines in sorted text files. Command grep is using options:
-F, –fixed-strings PATTERN is a set of newline-separated strings
-x, –line-regexp force PATTERN to match only whole lines
-f, –file=FILE obtain PATTERN from FILE

$ cat > list-a.txt <<END
> alpha
> beta
> gamma
> delta
> END

$ cat > list-b.txt <<END
> beta
> delta
> eta
> iota
> kappa
> lambda
> END


$ grep -F -x -f list-a.txt list-b.txt
beta
delta

This entry was posted in workday and tagged . Bookmark the permalink.

Leave a Reply