Linux 拨号vps windows公众号手机端

shell怎么去除字符串的双引号

lewis 8年前 (2017-07-18) 阅读数 8 #程序编程
文章标签 shell

在Shell中,可以使用${变量名//\"/}或者sed 's/\"//g'来去除字符串的双引号。

下面是一个例子:

str="\"Hello, world!\""
new_str=${str//\"/}
echo $new_str

输出结果为:

Hello, world!

或者使用sed命令:

str="\"Hello, world!\""
new_str=$(echo $str | sed 's/\"//g')
echo $new_str

输出结果也为:

Hello, world!
版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门