There are a few approaches you could take. If you're dealing with files of that size, just concatenating both files and only printing lines that appear once may be effective:
cat FILEA FILEB | sort | uniq -c | awk '$1==1{print $2}'
1.1.1.1
3.3.3.3
5.5.5.5
If the values won't be single "words" (i.e., you potentially have spaces and more fields on each line), then you could tell awk to print everything on the line after the uniq count of "1" on relevant lines:
cat FILEA FILEB | sort | uniq -c | awk '$1==1{print substr($0,index($0,"1 ")+2)}'
1.1.1.1
3.3.3.3
5.5.5.5
Of course, if you have lines in FILEA that may be duplicates within the file but you want to keep them because they don't appear in FILEB, that may require a different approach, like defining an array of values in FILEB and then checking each line in FILEA to see if it's in the array, like this:
awk 'BEGIN{ref="FILEB";while (getline < ref){remove[$0]};close(ref)}{if (!($0 in remove)){print}}' FILEA
1.1.1.1
3.3.3.3
5.5.5.5
4.4.4.4
in B is interpreted bygrep
as a regular expression (.
is not a literal dot in regex). Ask yourself if you want-F
and/or-x
(seeman 1 grep
). I guess-Fx
(if this is what you want) may reduce the need for memory, depending on the actual content of the files. In general using or not using-F
or-x
affects the output, so you need to be sure regardless of memory usage. For now I think you do need-Fx
.fileb
,FILEB
andFileB
are different names; so arefileA
FILEA
andFileA
. Your question is uncomplicated enough, so it's not a big problem for me to interpret the respective names as equivalent, still they don't look right. Please edit and make the question coherent.