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!