On Fri, Apr 08, 2016 at 09:26:47AM -0000, Charles T. Smith wrote:
> Does anybody know how to use ?(pattern)?  Or @(pattern)?  Or any of them
> except !(pattern)?  If you do an internet search, the man page is always
> blithely quoted, but only !(pattern) is ever demostrated...
> I wonder if the others even work?
> 
>               ?(pattern-list)
>                      Matches zero or one occurrence of the given patterns

imadev:~$ cd tmp
imadev:~/tmp$ ls
imadev:~/tmp$ shopt -s extglob
imadev:~/tmp$ touch a.foo b.bar c.gif d.jpg
imadev:~/tmp$ echo a.foo?(zebra)
a.foo

>               *(pattern-list)
>                      Matches zero or more occurrences of the given patterns

imadev:~/tmp$ echo a.f*(o)
a.foo

>               +(pattern-list)
>                      Matches one or more occurrences of the given patterns

imadev:~/tmp$ echo *.+(gif)
c.gif

>               @(pattern-list)
>                      Matches one of the given patterns

imadev:~/tmp$ echo *.@(foo|bar)
a.foo b.bar

>               !(pattern-list)
>                      Matches anything except one of the given patterns

imadev:~/tmp$ echo !(*.jpg)
a.foo b.bar c.gif

Reply via email to