On the command line, can I express easily in terms of shell globs that I would like to catch all files something-*.txt
, except for something-*-foobar.txt
? If I can, how?
NB: I know how to achieve the same with grep -v
or other combinations of multiple commands. The question is solely about whether (and if so how) to achieve this with shell globs.
Best Answer
You can enable
ksh
-style extended globbing with:And then write
something-!(*-foobar).txt