Array Head

Get the first n elements of an array.

Code

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

Parameters

Array (JSON)

Number of elements

Server

More Bash Snippets