小编Ogd*_*den的帖子

Pattern match does not work in bash script

Using the pattern match !("file1") does not work within a bash script but will work on the command line.

For example:

ls  !("file1"|"file2")
Run Code Online (Sandbox Code Playgroud)

This will list all files in directory except file1 and file2.

When that line is executed in a script this error is displayed:

./script.sh: line 1: syntax error near unexpected token `('
./script.sh: line 1: ` ls  !("file1"|"file2") ' 
Run Code Online (Sandbox Code Playgroud)

Regardless what is used rm -v !("file1"). The same error takes place. What is going on …

linux bash glob extglob

13
推荐指数
2
解决办法
469
查看次数

标签 统计

bash ×1

extglob ×1

glob ×1

linux ×1