How do I escape an exclamation mark in bash?

bash

Solution

Exclamation mark is preserved literally when you include it in a single-quoted string.

Example:

git commit -m 'Frustrating <insert object of frustration here>!'

Problem

Sometimes I feel the urge to put some more expressiveness in my git commit messages. Unfortunately bash does not seem to like this. ``` iblue@silence ~/git/wargames $ git commit -m "Frustrating <insert object of frustration here>!" -bash: !": event not found ``` Escaping with a backslash helps, but this includes the backslash in the commit message. How do I escape the exclamation mark in bash correctly?

Original source

Related problems