这是我要获得的输出。
"last_name:""abcd","email:""abc.com","first_name:""xyz"
所需的输出为:
"last_name":"abcd","email":"abc.com","first_name":"xyz"
使用 s
ubstitute 命令:
echo '"last_name:""abcd","email:""abc.com","first_name:""xyz"' |
sed 's/:""/":"/g'
输出:
"last_name":"abcd","email":"abc.com","first_name":"xyz"
这个简单的 sed
可能会在同一方面帮助您:
sed 's/:""/":"/g' Input_file
说明: sed
用目标(或新的字符串/值(":"
(在这种情况下(替换源:""
(在这种情况下(的方法。g
选项确保在线上全球发生替代。
解决方案2:现在也添加awk
解决方案:
awk '{gsub(/: 42 42/," 42: 42")} 1' Input_file
注意:如果要在input_file本身中保存输出,然后在上述代码中使用sed -i
,尽管sed
。