Fooblog

Foobar's blog and linkdump

!diff — Finding lines that are the same between 2 files

with one comment

Someone asked if there was a way for diff to only show lines that are the same between 2 files. A little digging in the manpage for gnu diff got me this nice result:

diff --unchanged-line-format=%L --old-line-format= --new-line-format= FILE1 FILE2

This seems to work… but i’m open to other suggestions

Be Sociable, Share!

Written by foobar

April 16th, 2009 at 2:08 pm

Posted in hacking,Just Blogging Stuff,tech

Tagged with , ,

One Response to '!diff — Finding lines that are the same between 2 files'

Subscribe to comments with RSS or TrackBack to '!diff — Finding lines that are the same between 2 files'.

  1. An ex collegue came up with the following, which also works quite nice (and is a lot easier)

    $ comm -1 -2 FILE1 FILE2

    comm is part of gnu coreutils

    Maniac

    20 Apr 09 at 21:31

Leave a Reply


× 6 = thirty