Why can't I use an exclamation point in bash 'echo even if it is escaped?

My question is simple:

$ echo "Hello!"
sh: !": event not found

What is !in this case? Then I tried echo "Match\!", but it is allowed before Match\!. How do I write an expression?

+4
source share
2 answers

You can use single quotes:

echo 'Hello!'
Hello!

Otherwise, the double-quoted shell tries to deploy !to an event from the story.

+3
source

You can disable the story extension with set +Hand enable it again withset -H

0
source

All Articles