Can U pipe filenames to rm???

Conor P. Cahill cpcahil at virtech.uucp
Sat Sep 29 09:38:43 AEST 1990


In article <28790001 at col.hp.com> greiner at col.hp.com (Mike Greiner) writes:
>
>                    Piping filenames to the rm command???
>
>I haven't figured out how to pipe this list of names to rm. 

You don't need to.  Pipe the list of names to  xargs rm.


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

Just change this to:

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

This, of course, assumes you have xargs.  If you don't, you can get one 
of the PD versions that have been posted to c.s.u in the past.

Otherwise, if you know that the length of the list is relatively short (i.e.
it wont overrun the command line buffer length) you can do the following:

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

else you could do the following:

     ninstall -h $1 -vvvvv -p $2 | grep path | cut -d " " -f4 | while read name
     do
         rm $name
     done

-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 



More information about the Comp.unix.shell mailing list