I have two large files A and B
I need to delete lines that appear in file B from file A and save the result
to file C
I have tried comm -23 file1
You can use the following:
grep -vxFf fileB fileA > fileC
Sample:
$ seq 5 > a # 1 to 5 in file a
$ seq 10 > b # 1 to 10 in file b
$ grep -vxFf a b > c
$ cat c
6
7
8
9
From man grep
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by POSIX.)
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.)
-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)
-x, --line-regexp
Select only those matches that exactly match the whole line. (-x is specified by POSIX.)