I'm trying to delete some files and folders from a directory. The command (from here):
rm -rf !(file_i_don't_want_to_remove|other|other_one)
Runs fine in terminal, but if I try to use it inside a script (created using vim, 2 lines):
#!/bin/bash
rm -rf !(one|two)
./file.sh: línea 2: error sintáctico cerca del elemento inesperado `('
Translated:
./file.sh: line 2: syntax error near of unexpected element `('
Why?
PS. I've looked for other questions with the same name but they're all too specific for each script and seem not to be the same problem than mine.
.txtor.jpgetc and delete them, just a suggestion.bashin your script as new as the one in your Terminal? You need to also setshopt -s extglobfor that I think.shoptcommand nor know what does it do. Going to research a bit. Thanks for the clue.