Bash Delete files with Exceptions

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

Delete except a file:

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

Posted

in

by

Tags:

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.