LoginSignup
5
8

More than 5 years have passed since last update.

bashでjqを使ってJSONのオブジェクトをループさせる

Posted at
map.json
{
  "key1": "val1",
  "key2": "val2"
}
#!/bin/bash

json=$(cat map.json)
for key in $(echo $json | jq -r keys[]); do
  echo "$key: $(echo $json | jq -r .$key)"
done

参考

bashでjqを使ってJSONの配列をループさせる

5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8