Rotate Array Right

Rotate array elements to the right 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