how to output quotes in bash prompt


In certain situations, quotes are required to be output in the command prompt. To do this, you may say why don’t use single quotes. Basically, that is able to handle most cases. However, single quotes prevent parsing environment variables. In this blog, we present a simple way to handle outputing quotes while parsing specifiled environment variables.

the method

Firstly, we use single quotes:

echo 'hello "margin"'

the output showing below:

hello “margin”

Try to display environment variables:

echo '"hello $PATH"'


“hello $PATH”

If we prefer the content of PATH!

echo '"'hello $PATH'"'

result is :

“hello /usr/sbin:/usr/bin:/sbin:/bin”

Pay your attention on the first 3 characters after echo, and the last 3 characters! They are ', ", '!!!!

Do I make sense? Have any question? Do not hesitate to ask me~

发布了279 篇原创文章 · 获赞 443 · 访问量 168万+


©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客