Sunday, 25 February 2018

linux - How to delete all files in a directory except some?


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?



Answer



What I do in those cases is to type


rm *

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.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...