How to delete .htaccess file recursive based on size or content

find . -type f -perm 0444 -name ".htaccess" -exec echo rm {} \;

You can use find to go recursively through multiple directories, search for files and execute a command like rm on the result.

find . -type f -perm 0444 -name ".htaccess" -exec echo rm {} \;
. current diretory / can be other path e.g. /etc
-type f search for files
-perm 0444 permission 0444
-exec CMD {} \; run command like rm on the result {}
verify output of find and remove echo to remove files

find -type f -name “.htaccess” -delete

Delete All .htaccess files from all directory and folders

Leave a Reply

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