4 ms·
As far as I'm aware, rm -f !(text.txt) isn't enabled by default, at least in bash. You have to enable extended globbing by running 'shopt -s extglob' first (or
by scrooched_moose 5y ago
As far as I'm aware, rm -f !(text.txt) isn't enabled by default, at least in bash. You have to enable extended globbing by running 'shopt -s extglob' first (or add it to your profile).
Great feature though, it adds a ton of extra pattern matching. Not (!) is definitely my most used though.
https://www.linuxjournal.com/content/bash-extended-globbing https://www.linuxjournal.com/content/bash-extended-globbing
- prussian 5y agoEven funner quirk with stuff like that: $ bash -c 'shopt -s extglob; rm -- !(x)' bash: -c: line 1: syntax error near unexpected token `(' bash: -c: line 1: `shopt -s extglob; rm -- !(x)' Because of the strangeness of the bash parser, the glob has to come on the preceding line: $ bash -c $'shopt -s extglob\nrm -- !(x)'