Delete All Files of a Specific Extension in Linux?

Last Updated on 21 October 2020

Are you looking for a single line command that removes all the current directory and all sub-folders of a specific extension? (eg: *.jpg). Here’s the solution.

find . -name "*.jpg" -delete

NOTE: Use this option with extreme caution. This Linux command will remove the entire files that ending with *.jpg. Be sure to check your directory is correct before running the command.

Disclaimer: If you don’t know about Linux or never use it before. Please don’t proceed this, this command is risky. Proceed at your own risk.