I want to remove all files in a directory while leaving just some specified files, they don't have anything in common by name. How could I achieve that?
For example, the file names I want to keep are:
file_1.png
, another_file.jpg
, some_music.mp3
Best Answer
If you are using bash:
The first line just activates extended pattern matching, and after that we use one of them:
and the pattern-list is a list of one or more patterns separated by a
|
.Or with
zsh
Or, more portable, using
find
: