Sent with Proton Mail secure email.

------- Original Message -------
On Tuesday, December 27th, 2022 at 1:46 PM, Vince Winter 
<[email protected]> wrote:


> Define strange stuff from diff?
> 
> On Tue, Dec 27, 2022, 13:35 Ben Koenig [email protected] wrote:
> 
> > Hi all,
> > 
> > I thought there was a command to do this but I'm having trouble finding it
> > and diff is doing strange stuff.
> > 
> > I have a csv file that grows over time. What I want to do is take a newer
> > version of the file, compare it to the old one, and only print the lines
> > that are different. This also needs to be easily automated within a BASH
> > script.
> > 
> > Are there options to diff that I'm missing or a different command that can
> > quickly print only those lines unique to the first file? I'm resisting the
> > urge to read the lines into a python list and compare manually.
> > 
> > -Ben

For some reason I never received the original email from Ben, only the replies.

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".

[reid@laptop pacemaker]$ diff /etc/services /tmp/services 
29d28
< discard         9/tcp           sink null

[reid@laptop pacemaker]$ diff --changed-group-format='%<' 
--unchanged-group-format='' /etc/services /tmp/services 
discard         9/tcp           sink null

Reply via email to