Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!rochester!kodak!ispd-newsserver!garden!weimer From: weimer@garden.kodak.COM (Gary Weimer (588-0953)) Newsgroups: comp.unix.questions Subject: Re: background foreach in csh or for in sh? Message-ID: <1991Mar26.162324.8426@ssd.kodak.com> Date: 26 Mar 91 16:23:24 GMT References: <1991Mar24.214129.3837@nntp-server.caltech.edu> <1991Mar25.231824.9992@ux1.cso.uiuc.edu> Sender: news@ssd.kodak.com Reply-To: weimer@ssd.kodak.com Organization: Eastman Kodak Co.; Rochester, NY Lines: 30 In article <1991Mar25.231824.9992@ux1.cso.uiuc.edu>, phil@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@ssd.kodak.com ( Gary Weimer )