Hi,
I have two files, in which the second file has exactly the same contents of the first file with some additional records. Now, if I want to remove those matching lines from file2 and print only the extra contents which the first file does not have, I could use the below unsophisticated command, consider f1 and f2 are the two files
Code:
var=`cat f1`
grep -v "$var" f2
but I need a more optimal solution with fast and reliable with less memory consumption.
I have found these 2 lines of code, but it does not work for files having lengthier lines:
Code:
fgrep -v -x -f f2 f1
awk 'NR==FNR {b[$0]; next} !($0 in b)' f2 f1