谁能解释一下:
- $bash
- $shopt -s extglob
- $ls *.(txt|doc)
- bash: Syntax error near unexpected token `('
- $shopt extglob
- extglob on
这是一个debian挤压安装.我期待extglob将括号解释为组的开头.
谢谢,
保罗
解决方法
因为extglob不起作用.你必须在模式列表的开头放置一个修饰符(在本例中为(txt | doc)),如下所示(来自man bash):
- ?(pattern-list)
- Matches zero or one occurrence of the given patterns
- *(pattern-list)
- Matches zero or more occurrences of the given patterns
- +(pattern-list)
- Matches one or more occurrences of the given patterns
- @(pattern-list)
- Matches one of the given patterns
- !(pattern-list)
- Matches anything except one of the given patterns
具体来说,ls *.*(txt | doc)产生我猜你想要的行为.