Black Friday 2025 – NPI EA (cat = Baeldung on Linux)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

Baeldung Pro – Linux – NPI EA (cat = Baeldung on Linux)
announcement - icon

Learn through the super-clean Baeldung Pro experience:

>> Membership and Baeldung Pro.

No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.

Partner – Orkes – NPI EA (tag=Kubernetes)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

1. Overview

Quoting in bash is really simple. However, sometimes, it becomes challenging when we add some restrictions. One such restriction is escaping a single quote within a single quote itself.

In this tutorial, we’ll discuss some of the ways to achieve this.

2. Using the Dollar ($) Symbol

In bash, strings starting with the dollar ($) symbol are treated specially. We can leverage this property to escape a single quote:

$ echo $'Problems aren\'t stop signs, they are guidelines'
Problems aren't stop signs, they are guidelines

Note that there’s a dollar ($) symbol at the beginning of the string.

3. Using the Escape Sequence

One more approach is to escape a single quote itself. Let’s divide the given string into three parts:

'Problems aren' + \' + 't stop signs, they are guidelines'

In the above example, the plus (+) symbol represents the concatenation operation. Let’s remove the plus symbol and space characters to achieve the desired result:

$ echo 'Problems aren'\''t stop signs, they are guidelines'
Problems aren't stop signs, they are guidelines

4. Conclusion

In this article, we discussed a few practical examples of using a single quote within a single quote itself. In the first example, we used the dollar ($) symbol, while the second example shows the usage of multiple single quotes.