Skip to content

Instantly share code, notes, and snippets.

@allanpedroni
Forked from matheusneder/pretty-json-output
Created July 8, 2019 11:35
Show Gist options
  • Save allanpedroni/303c7e9afaff7682d2915b98c8bdc442 to your computer and use it in GitHub Desktop.
Save allanpedroni/303c7e9afaff7682d2915b98c8bdc442 to your computer and use it in GitHub Desktop.
Format and colorize json output
#!/bin/bash
JQ_OUTPUT=$(mktemp)
cat /dev/stdin | while read -r l;
do
if echo $l | jq -C '.' > $JQ_OUTPUT 2>&1
then
cat $JQ_OUTPUT
else
echo $l
fi
done
rm $JQ_OUTPUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment