Saturday, February 16, 2008

Ubuntu: Find and remove files

In certain cases, you want to remove some files, which all have the same name, but perhaps in different folders. And if you're lazy like me, you don't want to go through all the directories and delete it manually. Well, here's a neat little command I found:

>find . -name file_name -print0 | xargs -0 rm

This will find all the files and remove them recursively. If you want to use a regular expression instead of a file name directly, you can use the -regex option instead of the -name option.


W

No comments: