So I’m trying to get the first column of comm output using awk.
I read that Tab was used as a separator for comm so I did:
awk -F"\t" '{print $1}' comm-result.txt
With comm-result.txt containing the output of:
comm -3 file1 file2
But this doesn’t seem to work.
This commend takes also the space character as a separator and I get weird results when my files contains multiple spaces.
How can i only get the first column from comm?
The first column of the “
comm file1 file2” output contains lines unique to thefile1. You can skip the post-processing by simply callingcommwith-2(suppress lines unique tofile2) and-3(suppress lines that appear in both files).However, if you have no choice but to process a pre-run output of
commthen as Carl mentioned,cutwould be an option:However, this result in empty lines for cases where column 1 is empty. To deal with this, perhaps
awkmay be more suitable: