Partition Array

Split an array into two arrays based on a condition, separating even and odd numbers.

Code

General
echo "$arr" | jq '[[.[] | select(. % 2 == 0)], [.[] | select(. % 2 != 0)]]'

Parameters

JSON array of numbers

Server

More Bash Snippets