How can I remove all "name" files in all of my subdirectories on Linux
2013-01-23 14:01
543 查看
Remove all *.swp files underneath the current directory, use the
The
Using
Option
Piping the output to
findcommand in one of the following forms:
find . -name \*.swp -type f -delete
The
-deleteoption means find will directly delete the matching files. This is the best match to OP's actual question.
Using
-type fmeans find will only process files.
find . -name \*.swp -type f -exec rm -f {} \;
find . -name \*.swp -type f -exec rm -f {} +
Option
-execallows find to execute an arbitrary command per file. The first variant will run the command once per file, and the second will run as few commands as possible by replacing
{}with as many parameters as possible.
find . -name \*.swp -type f -print0 | xargs -0 rm -f
Piping the output to
xargsis used form more complex per-file commands than is possible with
-exec. The option
-print0tells
findto separate matches with ASCII NULL instead of a newline, and
-0tells
xargsto expect NULL-separated input. This makes the pipe construct safe for filenames containing whitespace.
相关文章推荐
- one command to delete all files with name "filename" in current dir and all its sub-dirs
- "killall" to kill a group of processes on linux
- How can i get hold of all of the visible items in my QListView?
- How are the icon files in my application bundle used on iPad and iPhone?
- How can I set the background of UITableView (the tableview style is "Grouped") to use an image?
- (GCC) How can I hide "defined but not used" warnings in GCC?
- How to display "Writing language" menu automatically in edwin context menu on Symbian S60
- VC助手使用问题————all instance of the license"*" are in use .VA will be disabled
- How are the icon files in my application bundle used on iPad and iPhone
- Q&A: HOW TO FIX XCODE’S "USED AS THE NAME OF THE PREVIOUS PARAMETER" WARNING
- How can I put a checkbox in a column of my DataGrid?
- the diary of how to backup one more files in linux
- This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery
- How To Fix Xcode's "used as the name of&
- How can I put a checkbox in a column of my DataGrid?
- How can I make my existing HTML files work in XML?
- SQL Error (1235): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery
- How to remove all the empty files or directories?
- Hadoop Installation on a slow ubuntu laptop - Problem of the in-accessible "http://localhost:50030/jobtracker.jsp"
- How to use "man" effectively in the development of Linux