'foreach' help needed
Wolf N. Paul
wnp at dcs.UUCP
Sat Jul 2 23:07:11 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.
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 at dcs.UUCP TLX: 910-380-0585 EES PLANO UD
More information about the Comp.unix.questions
mailing list