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'` |
Another solution FFR:
find /path -name \*.tmp | xargs rm |
"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 |
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. |