IT Notes‎ > ‎Operation System‎ > ‎Linux‎ > ‎

Find and Delete Files with Extension Name

The directory contains many files to clean. All the files can be found and deleted by one single instruction:

$ find . -iname '*.cbp' -exec rm -rf {} \;

  • -iname 'name-pattern-to-search' : File pattern for insensitive search. The sensitive pattern is -name.
  • -exec rm -rf {} \; : Delete all files matched by file pattern.
Ref:
  1. https://stackoverflow.com/questions/5985752/linux-how-to-recursively-search-for-files-with-certain-extensions
  2. https://www.cyberciti.biz/faq/linux-unix-how-to-find-and-remove-files/



Comments