I have 2 files with a list of numbers (telephone numbers).
I'm looking for a method of listing the numbers in the second file that is not present in the first file.
I've tried the various methods with:
comm (getting some weird sorting errors)
fgrep -v -x -f second-file.txt first-file.txt (unsure of the result, there should be more)
This should work
It seems sort -n (numeric) cannot work with comm, which uses sort (alphanumeric) internally
f1.txt
f2.txt
21 should appear in third column
You need to use
comm
:will do the job.
ps. order of first and second file in command line matters.
also you may need to sort files before:
in case files are numerical add
-n
option tosort
.Basically looks for all lines in
second-file.txt
which don't match any line infirst-file.txt
. Might be slow if the files are large.Also, once you sort the files (Use
sort -n
if they are numeric), thencomm
should also have worked. What error does it give? Try this: