🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1327

Re: pipes within a script

#1327
From: Paul John Falstad
Date: Wed, 03 Oct 1990 04:45
50 lines
1707 bytes
In article <1263@umvlsi.ecs.umass.edu> breck@umvlsi.ecs.umass.edu (Liam Breck)
writes:
>I'm trying to write a C shell script in which I step through a bunch

Ah, there's your problem.  csh is horrible for shell scripts.  Use sh or ksh.

>#
>foreach dir (~/tex/ ~/tax/)
>   foreach file_ext (.aux .dvi .log .toc)
>      nohup echo $dir*$file_ext
>      end
>   end
>| rm

You can't do this in csh, as far as I know.  Even if you can, you should
use a /bin/sh script like this:

#! /bin/sh
rm `for dir in $HOME/tex/ $HOME/tax/; do
	for ext in .aux .dvi .log .toc; do
		echo $dir*$file_ext
	done
done | grep -v \\\*`

or else:

#! /bin/sh
for dir in $HOME/tex/ $HOME/tax/; do
	for ext in .aux .dvi .log .toc; do
		echo $dir*$file_ext
	done
done | grep -v \\\* | xargs rm

If you must use csh, do something like:

set nonomatch
echo {~/tex/,~/tax/,~/foo/}*.{aux,dvi,log,toc} | grep -v \\\* | xargs rm

or

set nonomatch
rm `echo { ... } | grep -v \\\*`

What was the nohup for, may I ask?

-----
Here is the address to complain to:
pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD CIS: 70016,1355
That address again,
sync@thumper.princeton.edu PLink:OHS738 GEnie:OHS738 CIS: 4128 143 1234 937
Technical Details
Message-ID: <3022@idunno.Princeton.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mephisto!udel!princeton!phoenix!pfalstad
References: <1263@umvlsi.ecs.umass.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mephisto!udel!princeton!phoenix!pfalstad
From: pfalstad@phoenix.Princeton.EDU (Paul John Falstad)
Newsgroups: comp.unix.shell
Subject: Re: pipes within a script
Message-ID: <3022@idunno.Princeton.EDU>
Date: 3 Oct 90 04:45:43 GMT
References: <1263@umvlsi.ecs.umass.edu>
Sender: news@idunno.Princeton.EDU
Distribution: usa
Organization: Princeton University, Princeton, New Jersey
Lines: 50