如何删除jq输出中的双引号以解析bash中的json文件? [英] How to remove double-quotes in jq output for parsing json files in bash?
本文介绍了如何删除jq输出中的双引号以解析bash中的json文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm using jq to parse a JSON file as shown here. However, the results for string values contain the "double-quotes" as expected, as shown below:
$ cat json.txt | jq '.name'
"Google"
如何将其传递到另一个命令中以删除"?所以我得到
How can I pipe this into another command to remove the ""? so I get
$ cat json.txt | jq '.name' | some_other_command
Google
我可以使用什么some_other_command
?
推荐答案
使用-r
(或--raw-output
)选项发出原始字符串作为输出:
Use the -r
(or --raw-output
) option to emit raw strings as output:
jq -r '.name' <json.txt
这篇关于如何删除jq输出中的双引号以解析bash中的json文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文