'foreach' help needed

David I. Berg dberg at cod.NOSC.MIL
Wed Jul 6 02:43:40 AEST 1988


In article <5639 at sgistl.SGI.COM>, larry at sgistl.SGI.COM (Larry Autry) writes:
> I would like some advice on what the syntax should be for 'foreach'. I
> already know it's use but I haven't seen any examples in documentation.
> -- 

foreach i (list)
	
	echo $i
	more script
	   |
	   |
	   |
	   V

end

where i is any variable name
  and list is a list of values to be given to i for each iteration
      through the foreach loop.  A continue statement in the loop 
      causes an unconditional branch to the end statment (to start
      the next iteration of the loop); a break statement in the loop
      causes an unconditional branch to the first statement following
      end (terminating the loop).  List can be constructed by executing
      a csh command, such as `cat file` or `ls xxxxx` where file contains 
      the list of variables to be given to i, or xxxxx is a directory name
      or a list of filenames.

The possibilities are endless.


-- 
David I. Berg (dberg at nosc.mil)
GENISYS Information Systems, Inc., 4250 Pacific Hwy #118, San Diego, CA 92110
MILNET: dberg at nosc.mil
UUCP:   {ihnp4 akgua decvax dcdwest ucbvax}!sdcsvax!noscvax!dberg



More information about the Comp.unix.questions mailing list