How to remove all files with specific extension in folder?

Delete all files with extension .tmp in current folder:

On Windows:

del *.tmp

On Mac:

rm -rf ./*.tmp


Delete all files with extension .tmp in current folder Recursively (including sub-folders):

On Windows:

del /s *.tmp

On Mac:

find . -name '*.tmp' -delete

you can delete files by using "del" command followed by star del *.class del * .txt


Using the find command will do the job efficiently.
Inside the folder,
find . -name "*.ext" -type f -delete

/!\ - Use this first to know what you are going to delete recursively.
find . -name "*.bak" -type f

Also, refer to the man find to know more about about it.

Tags:

Terminal

Cmd