Search code examples
linuxdiffcomm

Linux: Comparing two files but not caring what line only content


I am trying to use comm or diff Linux commands to compare to different files. Each file has a list of volume names. File A has 1500 volumes and file B has those same 1500 volumes plus another 200 with a total of 1700. I am looking for away to just find those 200 volumes. I dont care if the volumes match and are on different lines, I only want the mismatched volumes but the diff and comm command seem to only compare line by line. Does anyone know another command or a way to use the comm or diff command to find these 200 volumes?

First 5 lines of both files: (BTW there is only one volume on each line so File A has 1500 lines and File B has 1700 lines)

File A:

B00004
B00007
B00010
B00011
B00013

File B:

B00003   
B00004   
B00007    
B00008    
B00010 

So I would want the command to show me B00003 and B00008 just from the first 5 lines because those volumes are not in File A


Solution

  • awk can also help.

     awk  'NR==FNR {a[$1]=$1; next}!($1 in a) {print $0}' fileA fileB