cat ../2.json | jq 'map("curl -o " + .id + ".jpg "+ .avatar)|.[]'
#sed 文件首插入内容、文件尾部替换、文件尾部追加
sed '1i\{"useridlist":[' split.ab | sed '$ s/.$//' |sed '$ a\]}'| jq
#awk每5行插入内容
cat ../2.json | jq -r 'map("curl -o " + .id + ".jpg "+ .avatar+" ")|.[]' | awk '{if(NR%5==0)ORS="&&\n";else ORS=";\n"}1'
2.json 内容; 文章来源地址https://www.toymoban.com/news/detail-702274.html
[
{
"id": "281",
"avatar": "https://nim-nosdn.netease.im/MTEyNzU4MDQ=/bmltYV8xMjg0MTE3MTkyN18xNjA4MTI1MjM4MjQ1X2U5ZTYzMjVjLTViZGItNGNmMC1hOTAzLTFjMzhmMTcxN2RlMw=="
},
{
"id": "282",
"avatar": "https://nim-nosdn.netease.im/MTEyNzU4MDQ=/bmltYV8xMjg0MTI2NjQ5MV8xNjU1OTgwNzAxMTYzXzIwM2E0YjJkLTk1ZDUtNDQyYS04OGY3LWJhNGJmODZjMGViMA=="
}
}
文章来源:https://www.toymoban.com/news/detail-702274.html
到了这里,关于shell jq 迭代处理json数组的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!