[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Diff: obtain only the different lines of the newest file
From: |
Bob Proulx |
Subject: |
Re: Diff: obtain only the different lines of the newest file |
Date: |
Thu, 12 Aug 2010 22:41:45 -0600 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Davide Brini wrote:
> Bob Proulx wrote:
> > $ comm -13 /tmp/a /tmp/b
> > four
> > five
> > six
>
> I think this works by accident, since comm needs sorted files.
> I get this:
>
> $ comm -13 /tmp/a /tmp/b
> four
> comm: file 2 is not in sorted order
> five
> six
Oops! Yes, you are right. I had forgotten about that requirement.
My bad.
> Here's an awk solution, assuming the newer file has previously been
> determined (for example with stat as you suggest):
>
> awk 'NR==FNR{a[$0];next} !($0 in a)' oldfile newfile
>
> That prints lines in "newfile" that are not in "oldfile".
I like it.
Bob