From owner-freebsd-questions@FreeBSD.ORG Thu Sep 13 20:34:13 2007 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 9366E16A420 for ; Thu, 13 Sep 2007 20:34:13 +0000 (UTC) (envelope-from jonathan+freebsd-questions@hst.org.za) Received: from hermes.hst.org.za (onix.hst.org.za [209.203.2.133]) by mx1.freebsd.org (Postfix) with ESMTP id B163113C4D3 for ; Thu, 13 Sep 2007 20:34:11 +0000 (UTC) (envelope-from jonathan+freebsd-questions@hst.org.za) Received: from [10.1.11.1] ([10.1.11.1]) (authenticated bits=0) by hermes.hst.org.za (8.13.8/8.13.8) with ESMTP id l8DKTdA9075638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 13 Sep 2007 22:29:41 +0200 (SAST) (envelope-from jonathan+freebsd-questions@hst.org.za) From: Jonathan McKeown To: freebsd-questions@freebsd.org Date: Thu, 13 Sep 2007 22:38:36 +0200 User-Agent: KMail/1.9.4 References: <20070913175510.GA78984@gizmo.acns.msu.edu> In-Reply-To: Organization: Health Systems Trust X-Face: $@VrUx^RHy/}yu]jKf/<4T%/d|F+$j-Ol2"2J$q+%OK1]&/G_S9(=?utf-8?q?HkaQ*=60!=3FYOK=3FY!=27M=60C=0A=09aP=5C9nVPF8Q=7DCilHH8l=3B=7E!4?= =?utf-8?q?2HK6=273lg4J=7Daz?=@1Dqqh:J]M^"YPn*2IWrZON$1+G?oX3@ =?utf-8?q?k=230=0A=0954XDRg=3DYn=5FF-etwot4U=24b?=dTS{i X-Spam-Score: -4.188 () ALL_TRUSTED,AWL,BAYES_00 X-Scanned-By: MIMEDefang 2.61 on 209.203.2.133 Cc: Kurt Buff Subject: Re: Scripting question 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: Thu, 13 Sep 2007 20:34:13 -0000 On Thursday 13 September 2007 20:19, Kurt Buff wrote: > On 9/13/07, Jerry McAllister wrote: > > > The only space is the one separating the SMTP address from the OK or > > > NO. > > > > Then you should be able to tell it to sort on the first token in > > the string with white space as a separator and to eliminate > > duplicates. It has been a long time since I had need of sort. I > > don't remember the arguments/flags but am sure that type of thing can be > > done. You can use uniq if the file is already sorted (if not, put a sort at the start of the pipe) - after using awk to pick the first field: awk '{print $1}' inputfile | uniq -u > Ya know, it's really easy to get wrapped around the axle on this stuff. > > I think I may have a better solution. The file I'm trying to massage > has a predecessor - the non-unique lines are the result of a > concatenation of two files. > > Silly me, it's better to 'grep -v' with the one file vs. the second > rather than trying to merge, sort and further massage the result. The > fix will be to use sed against the first file to remove the ' NO', > thus providing a clean argument for grepping the other file. If it's two files and you want to select or reject common lines, look at comm(1) as another technique. Jonathan