错误
line 852: syntax error near unexpected token `('
第 852 行是函数的最后一行:
touch --reference="$KERNEL_FILE" "$moduledest"/modules.(*.bin|devname|softdep)
没有错误
当在 (
) 前插入感叹号 !
时:
touch --reference="$KERNEL_FILE" "$moduledest"/modules.!(*.bin|devname|softdep)
如何touch
!(*.bin|devname|softdep)
的逆函数?
/modules.alias.bin
/modules.builtin.bin
/modules.dep.bin
/modules.devname
/modules.softdep
/modules.symbols.bin
最佳答案
扩展 glob
您试图用感叹号否定匹配的模式是“扩展的 glob”。使用类似于 shopt -s extglob
的命令在脚本中的某处启用。
具有扩展通配语法的否定形式定义为 !(list)
:
!(list)
Matches anything but the given patterns.
在这种情况下,否定匹配的逆是语法 @(list)
:
@(list)
Matches one of the given patterns
关于bash - 为什么 (*.foo|bar) 会导致错误,而 !(*.foo|bar) 不会?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47742325/