Linux – Remove files recursively in Linux

fedoralinuxUbuntu

How to remove all the .pyc files recursively from a certain directory including sub-directories?
I tried

$rm -f *.pyc

This seems to work for only the current directory, but not the directories following it.
Please help me..

Best Answer

You can use

cd <your_directory>
find . -name "*.pyc" -exec rm -rf {} \;

This will remove all the *.pyc files from your current directory and its sub directory

Related Question