Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!ig!agate!helios.ee.lbl.gov!nosc!cod!dberg From: dberg@cod.NOSC.MIL (David I. Berg) Newsgroups: comp.unix.questions Subject: Re: 'foreach' help needed Keywords: csh foreach Message-ID: <1145@cod.NOSC.MIL> Date: 5 Jul 88 16:43:40 GMT References: <5639@sgistl.SGI.COM> Organization: Naval Ocean Systems Center, San Diego Lines: 35 In article <5639@sgistl.SGI.COM>, larry@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@nosc.mil) GENISYS Information Systems, Inc., 4250 Pacific Hwy #118, San Diego, CA 92110 MILNET: dberg@nosc.mil UUCP: {ihnp4 akgua decvax dcdwest ucbvax}!sdcsvax!noscvax!dberg