LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to do recursive file delete using specifier (*.tmp) from nested directories? (https://www.linuxquestions.org/questions/linux-general-1/how-to-do-recursive-file-delete-using-specifier-%2A-tmp-from-nested-directories-290602/)

Arodef 02-15-2005 02:22 PM

How to do recursive file delete using specifier (*.tmp) from nested directories?
 
I basically want to delete file matching a wildcard from a directory and all its subdirectories.

Examples:

mydelete *.tmp mydir/


So all the files ending with *.tmp in mydir/ and its subdirs would be deleted. How can I do this?


EDIT:
n/m, found the solution:

rm `find /home/user/path -name '*.tmp'`


sigsegv 02-15-2005 02:35 PM

Another solution FFR:

find /path -name \*.tmp | xargs rm

jailbait 02-15-2005 02:39 PM

"I basically want to delete file matching a wildcard from a directory and all its subdirectories."

find mydir/ -iname "*.tmp" -exec rm {} \;

See man find.

------------------------------
Steve Stites

vantoora 11-11-2009 07:49 AM

Delete file recursively
 
Dear all,
I have a similar problem with deleting some files recursively but more complex and I have not yet found a solution if anyone here can help me.

So my problem is this :
Suppose I have a root folder named 'vantoora' and have many subfolders inside 'eg. vantoora1, vantoora2... vantooraN'.
Inside of each subfolders there are two folders named 'new' and 'old' which contain many files each.

vantoora
|_ vantoora1
|_ new
|_ file1.txt
|_ old
|_ file1.txt
|_ file2.txt
|_ vantoora2
|_ new
|_ file1.txt
|_ file2.txt
|_ old
|_ file2.txt
:...
:...
|_ vantooraN
|_ new
|_ file1.txt
|_ file2.txt
|_ old
|_ file1.txt
|_ file2.txt

What I want to do is that search recursively for 'new' and/or 'old' and then delete every files inside those folders.

$ cd vantoora
$ vantoora > ls
$ vantoora > vantoora1 vantoora2 ... vantooraN

What I have done is following command but don't want to delete :
$ find -name 'new' | xargs ls "$1" /* to list all files inside all new folder */

tried :
$ find -name 'new' | xargs ls "$1" | xargs rm -f
but returned error something like : ls: cannot access ./vantoora/vantoora1...

All suggestions are welcome.
Thanks for you reply.


All times are GMT -5. The time now is 03:48 PM.