How to delete files starting with a specific letter

I want rm all the files in the directory, not starting with the letter I or N - what is the easiest way to do this in bash?

+4
source share
2 answers

You can do the following:

rm [^IN]* 

[^IN] is a pattern that matches any character except I or N - this syntax is described in the Matching Pattern section of the bash manual.

+13
source

Another way:

 find . -maxdepth 1 -type f -name "[^NI]*" -delete 

Obviously, this option is worse;)

+1
source

All Articles