Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 May 2009 14:29:18 -0700
From:      Kelly Jones <kelly.terry.jones@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Better version of diff?
Message-ID:  <26face530905171429x7cb58cbcv488b6d9397310a2e@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I often need to compare two Perl files sans comments. This mostly works:

egrep -v '^#' file1.pl > file1.tmp
egrep -v '^#' file2.pl > file2.tmp
diff -B file1.tmp file2.tmp

(yes, it breaks for perldoc style comments, comments on lines w/ code,
# characters inside HERE docs, and probably other cases-- just an
approximation)

I also often need to see if two files contain the same lines, minus
comments and allow duplicates. This mostly works:

egrep -v '^#' file1.txt | sort | uniq > file1.tmp
egrep -v '^#' file2.txt | sort | uniq > file2.tmp
diff -B file1.tmp file2.tmp;: comm would also work here

I could easily Perl script these two tasks, but my question is: has
anyone created a "super diff" that does this sort of thing and more?

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26face530905171429x7cb58cbcv488b6d9397310a2e>