Delete files recursively

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.

Buy me a coffee.
Your support help me to cover the cost of blogging. Thank you.
  • Archives