Skip to content
Advertisement

delete all files except a pattern list file

I need to delete all the files in the current directory except a list of patterns that are described in a whitelist file (delete_whitelist.txt) like this:

JavaScript

How can I perform this in one bash line?

Advertisement

Answer

Any bash script can fit on one line:

JavaScript

Check the output and then, if it’s OK:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement