Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Mar 1998 10:36:13 +1030
From:      Greg Lehey <grog@lemis.com>
To:        greg@merrimack.edu, FreeBSD Questions <questions@FreeBSD.ORG>
Subject:   Re: for loop at your command prompt
Message-ID:  <19980312103613.24718@freebie.lemis.com>
In-Reply-To: <3506FEC1.7D9312B2@merrimack.edu>; from Greg Fraize on Wed, Mar 11, 1998 at 04:14:41PM -0500
References:  <3506FEC1.7D9312B2@merrimack.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 11 March 1998 at 16:14:41 -0500, Greg Fraize wrote:
> can someone please tell me how I could do a
> for loop at my shell prompt...
> I've seen it done before...but I was un-able to remember what
> that person type ..thans

This is really a question for -questions, not -hackers.  I'm
redirecting accordingly.

That depends on your shell.  You *should*, of course, be using a
Bourne-style shell.  For that, the syntax is:

 for <name> in <list of things> do <things>; done

For example, to compare all the files in the current directory which
also exist in another directory, you might enter:

 otherdir=../foo		 # name of the other directory
 for i in *; do
   if [ -f $i -a -f $otherdir/$i ]; then
     cmp $i $otherdir/$i
   fi
 done

Greg

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?19980312103613.24718>