Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] bash and grep and diff



>> I often want to run diff on just a subset of two files. I.e.
>>   grep "ABC" a.txt >tmp1.txt
>>   grep "ABC" b.txt >tmp2.txt
>>   diff tmp1.txt tmp2.txt

Thanks to Edmund, Romeo, Attila, Pier, Stephen for the replies. Glad I
asked now!

> diff <(grep blah a.txt) <(grep blah b.txt)
> 
> the <() runs a sub-shell and uses /dev/fdX as input file for the
> diff command. ...

Very clever. I just discovered it also works with meld (a visual diff
program, written in python; it is lovely (*), but gets, very, very,
VERY, slow on large files, so being able to filter like this is great):
 meld <(grep blah a.txt) <(grep blah b.txt)

The filenames show up as /dev/fd/63 and /dev/fd/62.

Darren

*: You can click arrows to move blocks of differences from one file to
another, can delete lines, and in fact do any kind of edit on either
file. Horizontal scrollbars, so no more messing around with --width when
using --side-by-side. Really nice for checking and tidying up code
before an svn commit.


-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/gobet/  (Shodan Go Bet - who will win?)
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links