我有以下模式字符串:<SOMETHING_1>{<JSON>}<SOMETHING_2>
击子去除
我想保持<JSON>
并删除<SOMETHING_X>
块。我试图与子去除做到这一点,但是,而不是领
{x:1,action:PLAYING,name:John,description:Some description rSxv9HiATMuQ4wgoV2CGxw}
我不断收到
{x:1,action:PLAYING,name:John,description:Some}
因为在描述字段切断子的空白。
关于如何改变的想法?
CODE:
string="000{x:1,action:PLAYING,name:John,description:Some description rSxv9HiATMuQ4wgoV2CGxw}401"
string=$1
string=$(echo "${string#*{}")
string=$(echo "${string%}*}")
string={$string}
echo $string
你的JSON里面是否有散列{{}}? – codeforester
我没有得到你显示的输出。你如何将参数传递给脚本? – choroba
无论正确性如何,用于命令替换的子壳体的性能开销都有点不幸。 –