#json内容如下:
[email protected]#cat test.txt
[ { "id":"1" }, { "data":"231566" }, { "id":"2" }, { "data":"12345515" }, { "id":"3" }, { "data":"4124412512" } { "id":"4" }, { "data":"4231aaa24412512" } { "id":"5" }, { "data":"4122131zzc4412512" } { "id":"6" }, { "data":"4124423zsds12512" } ]
#过滤命令如下:
cat test.txt |grep -vE ‘({|}|\[|\])‘|cut -d: -f 2| cat test2.txt |grep -vE ‘({|}|\[|\])‘|cut -d: -f 2|sed ‘:a;N;$!ba;s/\n/ /g‘|awk ‘BEGIN{print"\n设置计数 器t=1";t=1}{for(i=1;i<NF;i++)if((i%2)!=0){t++;print "key:"$i,"valuse:"$(i+1)} else continue}END{print "循环次数:"t}‘
原文地址:https://www.cnblogs.com/lalalaxixixi/p/10771775.html
时间: 2024-11-06 09:26:44