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~

发布了279 篇原创文章 · 获赞 443 · 访问量 168万+
展开阅读全文

没有更多推荐了,返回首页

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

分享到微信朋友圈

×

扫一扫,手机浏览