Skip to content

Instantly share code, notes, and snippets.

@matheusneder
Last active July 8, 2019 11:35
Show Gist options
  • Save matheusneder/53e90f0d47a678dd14e1789eb1e84e37 to your computer and use it in GitHub Desktop.
Save matheusneder/53e90f0d47a678dd14e1789eb1e84e37 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