爲什麼這個命令行工作:感嘆號
$ 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