Sometimes, we need to delete all files with a specific extension in a linux directory. In this tutorial, we will introduce you how to do.
We can use linux rm command to do it.
For example, if we plan to remove all .wav files in the current directory, we can use command below:
rm *.wav
However, command above can not delete wav files in subdirectory. In order to delete all wav files that are also in subdirectories, we can use command below:
find /home/test -name "*.wav" | xargs rm
This command will delete all wav files in /home/test. However, if you only want to delete all wav files in your current directory, you can do as follows:
find . -name "*.wav" | xargs rm