Skip to content

Instantly share code, notes, and snippets.

@arc279
Last active April 19, 2018 08:36
Show Gist options
  • Save arc279/25c43b2f6b23f112a367f8c3578e433b to your computer and use it in GitHub Desktop.
Save arc279/25c43b2f6b23f112a367f8c3578e433b to your computer and use it in GitHub Desktop.
json配列を1行ずつに分割・それを戻す
$ cat <<EOD | jq -c '.[]'
> [ [ 11, 12, 13 ], [ 21, 22, 23 ], [ 31, 32, 33 ] ]
> EOD
[11,12,13]
[21,22,23]
[31,32,33]
$
$ cat <<EOD | jq -c '.[]' | jq -s 'reduce .[] as $i ([]; .+[$i])'
> [ [ 11, 12, 13 ], [ 21, 22, 23 ], [ 31, 32, 33 ] ]
> EOD
[
[
11,
12,
13
],
[
21,
22,
23
],
[
31,
32,
33
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment