Use find in Terminal to remove directories and files of same search parameter
If I type the following into Terminal, it will remove all files that meet the search parameter:
sudo find . -type f -name "*Xilisoft*" -exec rm -rf {} \;
Then if I start again and type it with d
instead of f
it will remove all the directories
sudo find . -type d -name "*Xilisoft*" -exec rm -rf {} \;
How do I get it to remove type f
and d
in one fell swoop?
You can provide multiple -type
options with -o
, such as -type f -o -type d
in a single command.
find . -name "*Xilisoft*" -type f -o -name "*Xilisoft*" -type d
-o
matches all parameters, so the -name
is provided twice in the above command.
Note that find can delete the results using -delete
rather than -exec rm -rf {}
.