#!/bin/bash tsv=$(jq 'def hdr:to_entries|map(.key); def vals:to_entries|map(.value|tostring); (arrays|[(first|hdr)]+[.[]|vals]) // (objects|[hdr]+[vals])|.[]|@tsv' -r) col=$(head -n1 <<<"$tsv" | tr '\t' ',' | tr '[:lower:]' '[:upper:]') if [ "$1" = "--headers" ]; then echo "$col" exit 1 fi exec column -s $'\t' --table --table-columns "$col" "$@" <(tail -n+2 <<<"$tsv")