[英]syntax error on bash rm -rf !; unexpected token
This command is working perfectly when you just type it into console and run; 当您将其键入控制台并运行时,此命令将完美运行。
rm -rf !(folder1|file_name|log.txt|*.sh|*.conf)
However, when I run it from a bash script, it gives me the following error; 但是,当我从bash脚本运行它时,出现以下错误;
./test.sh: line 1: syntax error near unexpected token `('
./test.sh: line 1: `rm -rf !(folder1|file_name|log.txt|*.sh|*.conf)'
It's the extended glob matching syntax. 这是扩展的glob匹配语法。 You need to enable it with
shopt -s extglob
before the rm
command. 您需要在
rm
命令之前使用shopt -s extglob
启用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.