Memoirs of a Technocrat

by Niroshan Rajadurai

  • Increase font size
  • Default font size
  • Decrease font size

Efficiently remove all files or directories with a particular name from your system

E-mail Print PDF
User Rating: / 1
PoorBest 

Useful UNIX scripting command.

If you have a common file or directory that needs to be removed from a directory tree, the following command can be useful for doing this:

find <starting_from_dir> -name <dir_OR_file_name> -exec /bin/rm -rf '{}' \;

This is ideal if you have spaces in the directory name, as the traditional method of using 'find' output inside a shell program will split the strings into blocks broken by white space. This will result in incomplete directory names.

Comments (0)