🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1416

Re: Can U pipe filenames to rm???

#1416
From: Jeff Beadles
Date: Sat, 06 Oct 1990 03:49
46 lines
2121 bytes
In <28790001@col.hp.com> greiner@col.hp.com (Mike Greiner) writes:

>                    Piping filenames to the rm command???

>I am trying to write a script to uninstall files installed via an
>ninstall package.  I can generate a list of filenames to delete, but
>I haven't figured out how to pipe this list of names to rm.  Here's
>the heart of my script so far, followed by its output:

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

>Now I want to pipe the output of this command into rm.  Here's the output:

>     /usr/local/doc/ninstall/UserGuide.mm
>     /usr/local/man/man1/ninstall.1
>     /usr/local/man/man1m/installd.1m

>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!

Well, a couple simple ways that will work most everywhere...

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

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

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

 4)  ninstall -h $1 -vvvvv -p $2 | grep path | cut -d " " -f4 | while read file
     ; do ; rm -f $file ; done


There are pitfalls with all.
	#1, #2, and #3 will all complain if there are no files to remove
	  if you don't use the "-f" flag.
	#1 will fail if there are too many files to delete, or the total size
	  of their pathnames is above a magic number.
	#3 requires xargs
	#2 and #4 are bourne shell specific.


Have fun!
	-Jeff
-- 
Jeff Beadles	jeff@onion.pdx.com
Technical Details
Message-ID: <1990Oct6.034922.8304@onion.pdx.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!onion!jeff
References: <28790001@col.hp.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!onion!jeff
From: jeff@onion.pdx.com (Jeff Beadles)
Newsgroups: comp.unix.shell
Subject: Re: Can U pipe filenames to rm???
Message-ID: <1990Oct6.034922.8304@onion.pdx.com>
Date: 6 Oct 90 03:49:22 GMT
References: <28790001@col.hp.com>
Reply-To: jeff@onion.pdx.com
Distribution: na
Organization: Little to none.
Lines: 46