The bash
shell supports extended globbing patterns if you enable them with
shopt -s extglob
Once enabled, the pattern !(*roc*)
would match any non-hidden name that does not match *roc*
, i.e. any name that does not contain the string roc
.
From the bash
manual:
If the extglob
shell option is enabled using the shopt
builtin,
several extended pattern matching operators are recognized. In the
following description, a pattern-list
is a list of one or more
patterns separated by a |
. Composite patterns may be formed using one
or more of the following sub-patterns:
?(pattern-list)
Matches zero or one occurrence of the given patterns
*(pattern-list)
Matches zero or more occurrences of the given patterns
+(pattern-list)
Matches one or more occurrences of the given patterns
@(pattern-list)
Matches one of the given patterns
!(pattern-list)
Matches anything except one of the given patterns