From owner-freebsd-questions@FreeBSD.ORG Tue Dec 16 17:32:58 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EF0CC16A4CE for ; Tue, 16 Dec 2003 17:32:58 -0800 (PST) Received: from ms-smtp-02-eri0.southeast.rr.com (ms-smtp-02-lbl.southeast.rr.com [24.25.9.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 75CDE43D64 for ; Tue, 16 Dec 2003 17:32:57 -0800 (PST) (envelope-from wegster@mindcore.net) Received: from mindcore.net (rdu162-234-100.nc.rr.com [24.162.234.100]) hBH1WlAb000265; Tue, 16 Dec 2003 20:32:47 -0500 (EST) Message-ID: <3FDFB23F.8030602@mindcore.net> Date: Tue, 16 Dec 2003 20:32:47 -0500 From: Scott W User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: mrb@bmyster.com References: <1191.66.63.97.2.1071610282.squirrel@new.host.name> In-Reply-To: <1191.66.63.97.2.1071610282.squirrel@new.host.name> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine cc: freebsd-questions@freebsd.org Subject: Re: comparison of files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2003 01:32:59 -0000 Brent Bailey wrote: >hello, > >I have been trying to write a shell script that will compare 2 files and >generate a 3rd. > >i have a list of abusive IP's generated by our router. I want to compare >it against a list of known abuse IPs ..and have it create a file of repeat >offenders. > >ive tired to use "comm" to compare file1 against file2 doing something like > >comm -12i file1 file2 >file3 > >however it doesnt seem to work....any suggestions ? > >thank you for all your help in advance > > You need to sort the files first...see below for difference in comm behavior... Script started on Tue Dec 16 20:27:59 2003 freeb# cat blacklist1 192.168.1.2 192.168.1.1 192.168.1.10 freeb# cat blacklist2 192.168.1.1 192.168.1.10 freeb# comm -i12 blacklist1 blacklist2 freeb# sort blacklist1 > blacklist1_sorted freeb# sort blacklist2 > blacklist2_sorted freeb# comm -i12 blacklist1_sorted blacklist2_sorted 192.168.1.1 192.168.1.10 Script done on Tue Dec 16 20:29:14 2003 Scott