Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!killer!dcs!wnp From: wnp@dcs.UUCP (Wolf N. Paul) Newsgroups: comp.unix.questions Subject: Re: 'foreach' help needed Keywords: csh foreach Message-ID: <134@dcs.UUCP> Date: 2 Jul 88 13:07:11 GMT References: <5639@sgistl.SGI.COM> Reply-To: wnp@dcs.UUCP (Wolf N. Paul) Organization: DCS, Dallas, Texas Lines: 29 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. I assume you mean the CSH construct equivalent to SH/KSH "for var in list do". Here is the syntax: foreach varname ( list ) command $varname ... end Here is an example: foreach file ( *.c ) mv $file $file.orig end Main differences from sh/ksh: parentheses around list, no "do/done", terminate with "end". Bugs: I've worked with versions of csh where the parentheses needed to be surrounded by whitespace -- i.e. it has to be " ( *.c ) " rather than "(*.c)". -- Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101 UUCP: killer!dcs!wnp ESL: 62832882 DOMAIN: wnp@dcs.UUCP TLX: 910-380-0585 EES PLANO UD