The extended glob syntax you are trying to use is turned off by default; you have to enable it separately in each script where you want to use it.
shopt -s extglob
Scripts should not use ls
though I imagine you were using it merely as a placeholder here.
More Related Contents:
- Move all files except one
- Why should eval be avoided in Bash, and what should I use instead?
- How to redirect output to a file and stdout
- How to kill a child process after a given timeout in Bash?
- ./configure : /bin/sh^M : bad interpreter [duplicate]
- The ‘eval’ command in Bash and its typical uses
- How to join multiple lines of file names into one with custom delimiter?
- Linux: copy and create destination dir if it does not exist
- How to redirect the output of the time command to a file in Linux?
- How to loop over directories in Linux?
- How to handle more than 10 parameters in shell
- How to count lines in a document? [closed]
- Is it OK to use the same input file as output of a piped command?
- Changing default shell in Linux [closed]
- Linux Script to check if process is running and act on the result
- Example of using named pipes in Linux shell (Bash)
- Passing variables in remote ssh command
- Escape filenames the same way Bash does it
- When to wrap quotes around a shell variable?
- How to determine SSL cert expiration date from a PEM encoded certificate?
- How to run a script at a certain time on Linux? [closed]
- How to get file creation date/time in Bash/Debian?
- Disable and re-enable address space layout randomization only for myself
- How to join multiple lines of filenames into one with custom delimiter
- Check if a variable exists in a list in Bash
- Doesn’t sh support process substitution
- Run script with rc.local: script works, but not at boot
- Maximum number of Bash arguments != max num cp arguments?
- Write a bash shell script that consumes a constant amount of RAM for a user defined time [closed]
- Using “$RANDOM” to generate a random string in Bash