This question already has an answer here:
- How to echo a bang! 6 answers
If I run
grep "!" test.txt
it will show error
bash: !: event not found
Well, I know I actually should use
grep '!'. But how to understand the above error?
! is bash special character. According to http://mywiki.wooledge.org/Quotes.
Double quotes: "..." prevents some substitutions but allows others. Every substitution that begins with a dollar sign $ is performed, as is the legacy
...(backtick) command substitution. Backslash escaping is also performed. No word splitting or filename expansion is performed.
It doesn't mention that double quotes will affect !. Could somebody explain how does bash or grep interpret
grep "!"? What is the "event"?