I'm using the command ls files/@(*.text|*.txt|*.xt)
to get all files that end with any of the patterns.
When I run it in the shell I get this result
$ ls files/@(*.text|*.txt|*.xt)
files/f1.text files/f1.txt files/f1.xt
When I create a bash script, it throws the error ls: cannot access files/@(*.text|*.txt|*.xt): No such file or directory
Here is a copy of my bash script
#!/bin/bash
ls files # this one works
ls files/@\(*.text\|*.txt\|*.xt\) # This doesn't work
full output when running the bash script
$ ./testScript.sh
files/f1.text files/f1.txt files/f1.xt
ls: cannot access files/@(*.text|*.txt|*.xt): No such file or directory
Confirmed the shell is a bash shell
$ echo $SHELL
/bin/bash
I also tried:
ls files/@\(*.text|*.txt|*.xt\)
- throwsline 4: *.xt): command not found
ls files/@(*.text|*.txt|*.xt)
- throwsline 4: syntax error near unexpected token
('`- running with
sh ./testScript.sh
- same error as original error. - using
/files/@(*.text|*.txt|*.xt)
- no luck (same error as above in this list)