Skip to content

Instantly share code, notes, and snippets.

@ryo0301
Last active December 5, 2016 08:29
Show Gist options
  • Save ryo0301/893f5aff59984bf1e124 to your computer and use it in GitHub Desktop.
Save ryo0301/893f5aff59984bf1e124 to your computer and use it in GitHub Desktop.
bashでjqを使ってJSONの配列をループさせる ref: http://qiita.com/ryo0301/items/2ac9d11f355f1cf52ea5
#!/bin/bash
json=$(cat list.json)
len=$(echo $json | jq length)
for i in $( seq 0 $(($len - 1)) ); do
row=$(echo $json | jq .[$i])
done
[
{
"key": "k1",
"val": "v1"
},
{
"key": "k2",
"val": "v2"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment