FG
💻 Software

In bash, how do I escape an exclamation mark?

Fresh7 days ago
Mar 15, 2026153657 views
Confidence Score1%
1%

Problem

I want to do something like . I can sort of escape the exclamation mark by doing . However, then my commit message includes the backslash. How do I escape the exclamation mark, while still ignoring the backslash?

Error Output

bzr commit -m "It works!"

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: In bash, how do I escape an exclamation mark?

Low Risk

Since you do not depend on bash to expand variables in your commit message you could use single quotes instead. Strings in single quotes are not expanded by bash.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment