The task is to delete files from the folder and sub-folders, maybe sub-sub-folder.
Say I want to delete .htaccess from every folder, but keep all others no-touch.
It is hard to go into each folder and delete the file. It takes time and also very easy to miss some folders.
There is one command in Linux. Great tool for it.
One line to do the job.

find . -name '.htaccess' -type f -print -exec rm -rf {} \;

See the details of this command line.
. dot means search from current folder.
-name ‘.htaccess’ means search based on file name, the file name is followed
-type f means the one searched is file
-exec it is very important. It followed by a command to run.
Then is a {} and a space and \ end with ;.
This command will show the results on screen.

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

Your email address will not be published. Required fields are marked *