#jq コマンドで #JSON 配列の shift & push 的なことをやる ( 配列の最初の要素を最後に入れ替える例 )


  • .[0:1] is first element of array
  • .[1:] is other elements of array exclude first element
  • we can concatenate arrays with plus operator +
$ echo '[1,2,3,4,5]' | jq ".[1:] + .[0:1]"
[
  2,
  3,
  4,
  5,
  1
]

Original by Github issue