Last active
July 8, 2019 11:35
-
-
Save matheusneder/53e90f0d47a678dd14e1789eb1e84e37 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