Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Nov 1998 11:49:18 -0800 (PST)
From:      David Wolfskill <dhw@whistle.com>
To:        freebsd-questions@FreeBSD.ORG, gmann@itw.com
Subject:   Re: sh programming question
Message-ID:  <199811181949.LAA05789@pau-amma.whistle.com>
In-Reply-To: <36531668.2C2CD440@itw.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>Date: Wed, 18 Nov 1998 13:48:08 -0500
>From: Glen Mann <gmann@itw.com>

>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



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