Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 18
    Downvote (with all respect): The Question is explicitly about escaping an exclamation mark. Your answer does solve the problem described above, is helpful as such, but it doesn't answer the question itself. I came here (using a search engine) with a slightly different problem and I need to really escape the exclamation mark (inside double quotes). Your workaround doesn't help me. If this question had a different title (e.g. "how to solve this exclamation mark problem") your answer would be perfectly fine. But as SO being a question & answer site, your answer misses the point. Commented Jan 6, 2018 at 10:31
  • 3
    I came with a question "How to keep bash from putting its fingers into my arguments" and this answer helped me. Commented Oct 30, 2023 at 12:26
  • 1
    Indeed, mug896 answer is better. Imagine the case when you already need the single quotes, for instance: psql -c "SELECT * FROM player WHERE name !~ '^admin'". Commented May 16, 2024 at 6:35