Bash 3.2.57 (on macOS 12.6.8) extended glob pattern negation is not working in parameter substitution:
$ shopt -s extglob
$ s=abc
$ echo ${s##!(a)*}
I expected the last command to output abc
, but it didn't output anything.
How can I make the third line output nothing if the first character of $s
is not 'a'
, but output $s
if the first character is 'a'
?
or
or
or, more like what you tried,
Extended globbing not needed.