如何使用Shell脚本解析JSON? [英] How to parse JSON with shell scripting?
本文介绍了如何使用Shell脚本解析JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JSON文件,我需要从中提取一些参数并将其写入另一个文件:
I have a JSON file from which I need to extract a few parameters and write into another file:
devDependencies": {
"gulp": "^3.9.1",
"gulp-angular-templatecache": "^1.9.1",
"gulp-bump": "^1.0.0"
}
我要编写一个仅包含
gulp gulp-angular-templatecache gulp-bump
如何使用shell脚本来做到这一点?
How can I do that using a shell script?
推荐答案
echo $(grep ^\" file| cut -d\" -f2)
但是您不应该使用bash进行任何更复杂的json解析.这也是一个骇人听闻的解决方案.
But you shouldn't do any more complex json parsing with bash. This is also a hackish solution.
这篇关于如何使用Shell脚本解析JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文