Array Tail

Get the last n elements of an array.

Code

General
echo "$arr" | jq --argjson n "$n" '.[-$n:]'

Parameters

Array (JSON)

Number of elements

Server

More Bash Snippets