I need to delete all files in a directory, but exclude some of them. For example, in a directory with the files a b c ... z
, I need to delete all except for u
and p
. Is there an easy way to do this?
Linux – How to Delete All Files in a Directory Except Some
bashlinuxrm
Best Answer
What I do in those cases is to type
Then I press Ctrl+X,* to expand
*
into all visible file names.Then I can just remove the two files I like to keep from the list and finally execute the command line.