我需要一些帮助。 我正在尝试做这样的事情
echo "{
"server":"$SERVER_HOST",
"server_port":"$SERVER_PORT",
"password":"$PASSWORD_CHOICE",
"timeout":$TIMEOUT_CHOICE
}" >> /etc/ss/example.json
我需要像这样的输出
{
"server":"127.0.0.1",
"server_port":80,
"password":"randompassword",
"timeout":60
}
但是输出总是这样
{
server:127.0.0.1,
server_port:80,
password:randompassword,
timeout:60
}
最佳答案
不要使用 echo
,而是使用 cat
与此处文档:
cat >> /etc/ss/example.json <<EOF
{
"server":"$SERVER_HOST",
"server_port":"$SERVER_PORT",
"password":"$PASSWORD_CHOICE",
"timeout":$TIMEOUT_CHOICE
}
EOF
关于json - 如何在 echo 中添加引号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61576308/