Quantcast
Channel: Remove all files except some from a directory - Stack Overflow
Viewing all articles
Browse latest Browse all 21

Answer by Dennis Williamson for Remove all files except some from a directory

$
0
0

Assuming that files with those names exist in multiple places in the directory tree and you want to preserve all of them:

find . -type f ! -regex ".*/\(textfile.txt\|backup.tar.gz\|script.php\|database.sql\|info.txt\)" -delete

Viewing all articles
Browse latest Browse all 21

Trending Articles