Why does this command line work:
$ output='Irrelevant'; if [[ $output =~ Something ]]; then echo "I found something in the output." ; fi
And this one give me a strange parse error?
$ output='Irrelevant'; if [[ $output =~ Something ]]; then echo "I found something in the output!" ; fi
-bash: !": event not found
The only change from the first version is that the sentence to be echoed inside quotes ends with an exclamation mark. Why does Bash give me that error in the second version?
In case it matters, this is the output from bash --version
:
GNU bash, version 4.2.24(1)-release (x86_64-pc-linux-gnu)