为什么这个命令行工作:感叹号
$ output='Irrelevant'; if [[ $output =~ Something ]]; then echo "I found something in the output." ; fi
而这一次给我一个奇怪的语法错误?
$ output='Irrelevant'; if [[ $output =~ Something ]]; then echo "I found something in the output!" ; fi
-bash: !": event not found
从第一个版本的唯一的变化是这句话里面引号里回荡着一个感叹号结束。 为什么Bash在第二个版本中给我这个错误?
在如此重要的情况下,这是从bash --version
输出:
GNU bash, version 4.2.24(1)-release (x86_64-pc-linux-gnu)
相关:https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash – codeforester