[comp.unix.shell] recursively deleting *.dvi files

haozhou@acsu.buffalo.edu (hao zhou) (10/20/90)

I want to write some script for deleting *.dvi files recursively in
all my subdirectories but I haven't got any idea yet. Can somebody
shed some light on this?

	-- HaoZ.

-- 
Internet:haozhou@acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu@UBVM.BITNET
UUCP: uunet!acsu.buffalo.edu!haozhou

rouben@math9.math.umbc.edu (Rouben Rostamian) (10/20/90)

In article <41724@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
 >I want to write some script for deleting *.dvi files recursively in
 >all my subdirectories but I haven't got any idea yet. Can somebody
 >shed some light on this?
 >

Not need for a script.  To delete *.dvi files in the current directory 
and all its subdirectories, do:

    find . -name '*.dvi' -print | xargs rm

--

sean@utodaycom (Sean Fulton) (10/21/90)

In article <41724@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
>I want to write some script for deleting *.dvi files recursively in
>all my subdirectories but I haven't got any idea yet. Can somebody
>shed some light on this?
>

Try:
	find . -name `*.dvi` -print -exec rm -f {} \;


-- 
Sean Fulton					sean@utoday.com
UNIX Today!					(516) 562-5430
 /* The opinions expressed above are not those of my employer */

jik@athena.mit.edu (Jonathan I. Kamens) (10/22/90)

In article <1828@utodaycom>, sean@utodaycom (Sean Fulton) writes:
|> Try:
|> 	find . -name `*.dvi` -print -exec rm -f {} \;

  Backquotes won't do the right thing in any of the shells I've used.

  Backquotes are for command evaluation and output substitution, not for
wildcard quoting.  The command above will try to run a command called "*.dvi",
which will obviously fail.  Try:

	find . -name '*.dvi' -print -exec rm -f {} \;

Or, if you know there aren't that many of them, try:

	rm -rf `find . -name '*.dvi' -print`

Or, if you are unsure how many of them there are and you have xargs (and you
aren't worried about the xargs security holes that have been discussed
recently being present in your home directory :-):

	find . -name '*.dvi' -print | xargs rm -f

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710