Rotate Array Left

Rotate array elements to the left by a specified number of positions, wrapping elements around.

Code

General
echo "$arr" | jq --argjson n "$n" '($n % length) as $k | .[$k:] + .[:$k]'

Parameters

Array to rotate (JSON)

Positions to rotate

Server

More Bash Snippets