Take While

Take elements from the start of an array while a condition is true.

Code

General
echo "$arr" | jq --argjson t "$threshold" '. as $a | (first(range(length) | select($a[.] >= $t)) // length) as $i | .[:$i]'

Parameters

Array (JSON)

Take while less than threshold

Server

More Bash Snippets