Bash Escape Single Quote

Bash escape single quotes

In this tutorial, we will see how to escape single quote in Bash. There are multiple ways to escape single quote in Bash. Let’s go through them.

Using Double Quotes

Use double quotes to escape single quote in Bash.

Using Backslash Character

Use a backslash character (\) to escape a single quote in Bash. We use this approach if the string is enclosed within the single quotes.

The \' must be wrapped with single quotes in the above example.

Using $'...' Syntax

Use the $'...' syntax to escape a single quote in Bash. Inside the $'...', the backslash character is used to escape the single quote.

That’s all about Bash escape single quote.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *