From owner-freebsd-questions@FreeBSD.ORG Mon May 18 04:57:34 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDE1D10656A5 for ; Mon, 18 May 2009 04:57:34 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email1.allantgroup.com (email1.emsphone.com [199.67.51.115]) by mx1.freebsd.org (Postfix) with ESMTP id A9BAC8FC18 for ; Mon, 18 May 2009 04:57:34 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email1.allantgroup.com (8.14.0/8.14.0) with ESMTP id n4I4vXCe080136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 17 May 2009 23:57:33 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id n4I4vW2r043707 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 17 May 2009 23:57:32 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.3/Submit) id n4I4vVhH043694; Sun, 17 May 2009 23:57:31 -0500 (CDT) (envelope-from dan) Date: Sun, 17 May 2009 23:57:31 -0500 From: Dan Nelson To: Kelly Jones Message-ID: <20090518045730.GE52703@dan.emsphone.com> References: <26face530905171429x7cb58cbcv488b6d9397310a2e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26face530905171429x7cb58cbcv488b6d9397310a2e@mail.gmail.com> X-OS: FreeBSD 7.2-STABLE User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: ClamAV version 0.94.1, clamav-milter version 0.94.1 on email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Sun, 17 May 2009 23:57:33 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: freebsd-questions@freebsd.org Subject: Re: Better version of diff? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 04:57:35 -0000 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