how to output quotes in bash prompt


introduction


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"'

outputs
“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~