background foreach in csh or for in sh?
Gary Weimer 588-0953
weimer at garden.kodak.COM
Wed Mar 27 02:23:24 AEST 1991
In article <1991Mar25.231824.9992 at ux1.cso.uiuc.edu>,
phil at ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
|> Is it that complicated to run a new shell? I assume you are using csh.
|> Use the "-f" option to supress ".cshrc" execution for faster startup of
|> the subshell.
|>
|> echo 'foreach number ( 0 1 2 3 4 5 6 7 8 9 )\
|> echo the number is $number\
|> end' | csh -f &
I use this so often, that I've written an alias for it:
alias loop '(echo foreach x\(\!:1\);echo \!:2*;echo end)|csh -f &'
To use the alias:
loop '0 1 2 3 4 5 6 7 8 9' 'echo the number is $x'
(Note that the loop variable is always $x)
If you don't use the single quotes, you will have to escape $, *, etc.
I often use this on my server for more complicated things like:
loop '/export/root/*/etc' 'mv $x/printcap $x/printcap.orig; cp
/etc/printcap $x/printcap'
(should be all one line)
This will install the server's new /etc/printcap file on all it's clients.
weimer at ssd.kodak.com ( Gary Weimer )
More information about the Comp.unix.questions
mailing list