Ha, I knew one of these GNU tools could do it! I nearly gave myself a migraine 
struggling to remember which command did this. I kept landing on cmp but it 
works byte-for-byte.

For the example above, just do:

bash-5.1$ comm -1 -3  a.csv b.csv 
2,m
4,d
5,e
6,f

And Bob's (literally) my uncle. Thanks Rich!
-Ben


------- Original Message -------
On Tuesday, December 27th, 2022 at 2:10 PM, Rich Shepard 
<[email protected]> wrote:


> On Tue, 27 Dec 2022, Reid wrote:
> 
> > You could try something like `diff --changed-group-format='%<' 
> > --unchanged-group-format=''`, or one of its variants. That example assumes
> > that the first file is the one you want lines from. Check the diff man
> > page under "--GTYPE-group-format=GFMT".
> 
> 
> diff -y shows differences, but both files being compared. On the other hand
> (besides four fingers and a thum) there's comm:
> 
> man comm:
> NAME
> comm - compare two sorted files line by line
> 
> SYNOPSIS
> comm [OPTION]... FILE1 FILE2
> 
> DESCRIPTION
> Compare sorted files FILE1 and FILE2 line by line.
> 
> When FILE1 or FILE2 (not both) is -, read standard input.
> 
> With no options, produce three-column output. Column one contains lines 
> unique to
> FILE1, column two contains lines unique to FILE2, and column three contains 
> lines
> common to both files.
> 
> -1 suppress column 1 (lines unique to FILE1)
> 
> -2 suppress column 2 (lines unique to FILE2)
> 
> -3 suppress column 3 (lines that appear in both files)
> 
> --check-order
> 
> It's really handy and will do what Ben wants.
> 
> Rich

Reply via email to