Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete a filetype from a directory/subdirectory

Status
Not open for further replies.

Naoise

Programmer
Dec 23, 2004
318
IE

I want to delete all *.bak files from a dir/subdirs. Bash shell.

Something along the lines of rm -rf *.bak <mydir>

I realise this will not work, just used it to illustrate.

Any ideas?
 
Hi,

man find

Code:
find /some/path -type f  -name "*.bak" -exec rm {} \;
 
Another (faster) way:
find /path/to/dir -type f -name '*.bak' | xargs rm -f

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top