I want to rm all files in a directory not starting with the letter I or N - what is the easiest way to do it in bash?
You can do the following:
rm [^IN]*
The [^IN]
is a pattern that matches any character except I
or N
- this syntax is described in the Pattern Matching section of the bash manual.
Another way:
find . -maxdepth 1 -type f -name "[^NI]*" -delete
Obviously, this option is worse ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With