Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!news.cs.indiana.edu!ux1.cso.uiuc.edu!phil From: phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) Newsgroups: comp.unix.questions Subject: Re: background foreach in csh or for in sh? Message-ID: <1991Mar25.231824.9992@ux1.cso.uiuc.edu> Date: 25 Mar 91 23:18:24 GMT References: <1991Mar24.214129.3837@nntp-server.caltech.edu> Organization: University of Illinois at Urbana Lines: 38 gwoho@nntp-server.caltech.edu (g liu) writes: >how do i do a foreach or for in the background without >writing a script file or explicitly running a new shell >or something complicated like that?? >is there a simple way to do it? >gwoho liu. 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 & Note that you MUST use SINGLE quotes here, NOT double quotes. The reason is because a double quote will allow the $number variable to be interpreted in your command level shell, and it is either undefined or won't have what you want in it. The backslashes are to put newlines into the data echoed by the first echo. When I do these types of things, I FIRST test the echo data by NOT piping it into the subshell: echo 'foreach number ( 0 1 2 3 4 5 6 7 8 9 )\ echo the number is $number\ end' Then when I decide I did it right, I type this: !! | csh -f & and it will take off. -- /***************************************************************************\ / Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu \ \ Lietuva laisva -- Brivu Latviju -- Eesti vabaks / \***************************************************************************/