I ran
/bin/find /home/user/myfiles \! -name '.htaccess' -exec rm -r {} \;
and it removed everything in myfiles and the myfiles directory itself if .htaccess doesn't exist.
What I was expecting is that it would find and remove files within the directory, except for any .htacess file.
What did I do wrong?
rm -ron everything it finds, so it is not at all strange that it removes everything. I would also expect it to possibly emit error messages when it tries to enter directories that it has already deleted. – Kusalananda Aug 31 '22 at 17:45\! -nameclause “working fine” or is it removing the entire directory tree? – G-Man Says 'Reinstate Monica' Aug 31 '22 at 22:03.htaccessis not present as it won't remove a non-empty directory. – Mark Lane Sep 01 '22 at 03:17