-
-
Save allanpedroni/303c7e9afaff7682d2915b98c8bdc442 to your computer and use it in GitHub Desktop.
Format and colorize json output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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