16

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?

23

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 {}.

  • 3
    I didn't know about the -delete option so this comes as a welcome piece of information. – Danijel-James W Feb 11 '14 at 10:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .