-bash: !": event not found [closed]

How do I fix this bash terminal? Why would the '!' suddenly be a problem and the need for quotation marks are no longer seem to be necessary to produce the string. Did I break something? If so how do I reset it to factory setting? I'm sure it was working properly yesterday

Last login: Sat Oct 18 15:30:48 on ttys001 Michels-MacBook-Pro:~ michelfrechette$ echo "hello, world!" -bash: !": event not found Michels-MacBook-Pro:~ michelfrechette$ echo hello, world hello, world Michels-MacBook-Pro:~ michelfrechette$ echo "hello, world" hello, world 

-bash: !": event not found, this is curious.

2

1 Answer

Running

set +H 

will turn off the offending (history expansion) functionality in its entirety. Putting this in your ~/.bashrc is a common practice.

Alternately, you can modify the histchars variable to change the characters used to trigger history expansion (by default, !), quick substitution (by default, ^) and comments (by default, #).

As yet another option, using single- rather than double-quotes avoids triggering the shell feature in question.

2

You Might Also Like