Bash Delete files with Exceptions

find . \( \ ! -path '.' \ ! -iname '.env' \ \ ! -path './config' \ \ ! -path './logs' \ ! -path './logs/*' \ \ \) -delete # or -print
Code language: Bash (bash)

Delete except a file:

find . \( \ ! -path '.' \ ! -iname 'index.php' \ \) -delete
Code language: JavaScript (javascript)

Posted

in

by

Tags:

Comments

Leave a Reply

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