Re:Shell Magic: Set Operations with uniq
by raverbashing on Wednesday May 30, 2018 @03:40AM
(#17185825)
comm is probably the most useful command I never remember how it is called (and apropos doesn't help).
[ Parent
| on HN ]
The only options you usually need for comm are -1, -2, and -3. It takes two arguments, call them 1 and 2. Its job is to include lines from each and both files in output (by default, you get 3 columns of output), so we want to filter by telling it to exclude what we don't want. My mnemonic is "-" means "not", so -1 means "not only in file 1", -2 means "not only in file 2", and -3 means "not in both". So now, when I want comm output that shows the lines unique to my 2nd file, it's:
comm "not only in 1" and "not in both"
so:
comm -1 -3 file1 file2
Re:Shell Magic: Set Operations with uniq
by raverbashing on Wednesday May 30, 2018 @12:34PM
(#17189129)
I know how to use 'man', what I mean is, I never remember the command name (comm) because I always remember it's a command to compare so I think of cmp, and not comm.