My requirement is that i have two files file1 and file2. file1 content is present in file2. i want to have a final which will have file2 contents but not the contents of file1 so I am running below command.
fgrep -vf file1 file2>file3
no of records in file1 is 65282
no of records in file2 is 88187
and fgrep -v is taking 25Minutes to complete the operation
Is there any other way we can do same operation in less time?
awk 'NR==FNR {T[$1$2$3]; next} # suck in file1 into array T, indexed by $1, $2, $3 concatenated
($2$3$4 in T) {next} # if concat. $2, $3, $4 found in T, record existed in file1, read next line, start over
1 # print the orig. line from file 2, as not in file1
' file1 file2
Regarding above code. I just found that if content of file1 is zero then its not working. Ideally even if size of file1 is zero it should return all the content of file2.