Can anyone explain this:
$ bash
$ shopt -s extglob
$ ls *.(txt|doc)
bash: syntax error near unexpected token `('
$ shopt extglob
extglob on
This is a debian squeeze install. I am expecting the extglob will interpret the brackets as the beginning of a group.
Thanks,
Paul
Because extglob doesn't work that way. You must put one of the modifier characters at the beginning of your pattern list (
(txt|doc)
in this case), as follows (fromman bash
):Specifically,
ls *.*(txt|doc)
produces the behaviour I am guessing you want.You can do this without the extended globbing using brace expansion:
ls *.{txt,doc}