Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 May 2009 23:57:31 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Kelly Jones <kelly.terry.jones@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Better version of diff?
Message-ID:  <20090518045730.GE52703@dan.emsphone.com>
In-Reply-To: <26face530905171429x7cb58cbcv488b6d9397310a2e@mail.gmail.com>
References:  <26face530905171429x7cb58cbcv488b6d9397310a2e@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (May 17), Kelly Jones said:
> 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

Take a look at the -I option to diff.  It lets you ignore lines matching a
specified regex.

> (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

No suggestions here.  Sorting a file is not something diff should do imho.

-- 
	Dan Nelson
	dnelson@allantgroup.com



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