Reputation: 71
I can't find out what's happening. Is this regular expression not working for shell scripts?
sudo rm -R -f '/web/!(release)'
Any ideas?
thanks
Upvotes: 1
Views: 98
Reputation: 71
shopt -s extglob
sudo rm -R -f 'web/'!(release);
script.sh: Syntax error: "(" unexpected
edit :
I was running with "sh" instead of bash
now with bash script.sh it works
thanks
Upvotes: 1
Reputation: 75458
Perhaps you forgot to enable extglob
. Also you shouldn't quote your extended glob pattern:
shopt -s extglob
sudo rm -R -f '/web/'!(release)
Also if the shell you're calling sudo
with is not able to access /web
, you can wrap up your command with bash
:
sudo bash -c "shopt -s extglob"$'\n'"rm -R -f '/web/'!(release)"
See Pattern Matching and Filename Expansion.
Upvotes: 1