From owner-freebsd-questions Wed Nov 18 11:52:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA27496 for freebsd-questions-outgoing; Wed, 18 Nov 1998 11:52:11 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from pau-amma.whistle.com (s205m64.whistle.com [207.76.205.64]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA27491 for ; Wed, 18 Nov 1998 11:52:09 -0800 (PST) (envelope-from dhw@whistle.com) Received: (from dhw@localhost) by pau-amma.whistle.com (8.9.1/8.9.1) id LAA05789; Wed, 18 Nov 1998 11:49:18 -0800 (PST) (envelope-from dhw) Date: Wed, 18 Nov 1998 11:49:18 -0800 (PST) From: David Wolfskill Message-Id: <199811181949.LAA05789@pau-amma.whistle.com> To: freebsd-questions@FreeBSD.ORG, gmann@itw.com Subject: Re: sh programming question In-Reply-To: <36531668.2C2CD440@itw.com> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >Date: Wed, 18 Nov 1998 13:48:08 -0500 >From: Glen Mann >In a Bourne shell script, I want to compare two lists, obtained e.g. >with > list1=`ls $dirname1` > list2=`ls $dirname2` >in order to determine what elements are in list1 and list2, or in one >but not the other. The two lists will always be sorted, but not >necessarily directory listings. I'd like to do this without using >temporary files. I could use arrays in a Bash script and step through >the lists, but want to stick with sh. Is there an easy way to do this, >perhaps using sort and uniq? If the lists are already sorted, I doubt that sort will be a whole lot of use. However, you may find "diff" and its relatives handy. david -- David Wolfskill UNIX System Administrator dhw@whistle.com voice: (650) 577-7158 pager: (650) 371-4621 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message