您的位置:首页 > 运维架构 > Shell

how to output quotes in bash prompt

2015-04-04 17:22 393 查看

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~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: