来自: https://zhidao.baidu.com/question/369911229489608484.html time=`cat json|awk -F"[xxx]" '/xxx/{print $x}'` json.txt: { "people": [ { "firstName": "Brett", "lastName": "McLaughlin", "email": "aaaa" }, { "firstName": "Jason", "lastName": "Hunter", "email": "bbbb" }, { "firstName": "Elliotte", "lastName": "Harold", "email": "cccc" } ] } cat json.txt | awk -F "[firstName]" '/firstName/{print$0}' [root@localhost liu]# more json.txt | awk -F "[firstName]" '/firstName/{print$0}' [root@localhost liu]# less json.txt | awk -F "[firstName]" '/firstName/{print$0}' 输出到一个文件 less json.txt | awk -F "[firstName]" '/firstName/{print$0}' > out.log 结果: "firstName": "Brett", "firstName": "Jason", "firstName": "Elliotte", less out.log | awk -F "[:]" '/firstName/{print$2}' 结果: "Brett", "Jason", "Elliotte",
shell脚本如何从json文件读取一个某个值
最新推荐文章于 2024-08-09 23:54:45 发布