Can U pipe filenames to rm???

Kim Christian Madsen kimcm at diku.dk
Sat Sep 29 10:11:51 AEST 1990


greiner at col.hp.com (Mike Greiner) writes:


>                    Piping filenames to the rm command???

>    ninstall -h $1 -vvvvv -p $2 | grep path | cut -d " " -f4

>There may be a pretty simple solution to this, but I haven't found it.  I'm
>considering using a for-loop that parses each line as the loop counter, 
>but don't know if that's the best approach...appreciate any suggestions!

If you're sure the output of the ninstall does not exceed the limit of
what the shell you're using can handle (Bourne shell usually 5Kbytes),
you can use the following approach:

	ninstall .... | xargs rm

However, if the filelist from ninstall et al. does exceed the shell buffer
limit you can do something like (assuming Bourne shell):

	ninstall |
	while read filename
	do
		rm $filename
	done

					Kim Chr. Madsen



More information about the Comp.unix.shell mailing list