Last active
June 30, 2021 10:36
-
-
Save ichux/89338a85e605df27f7b3879555c63601 to your computer and use it in GitHub Desktop.
echo json to formatted 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/sh | |
printf "\033c" | |
echo '{ | |
"company": "PITCH CARDINAL CODING LIMITED", | |
"rc_no": "1387119", | |
"established": "2017-01-25", | |
"address": "1B, MARKET STREET, OYINGBO" | |
}' | python -m json.tool # > result.json | |
echo "" | |
# | |
(cat <<EOF | |
{ | |
"ip": "127.0.0.1", | |
"requestpath": "requestpath", | |
"httpmethod": "httpmethod", | |
"useragent": "Mozilla/5.0 (Windows NT 5.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0 `date +%s`", | |
"userplatform": "Linux", | |
"userbrowser": "Mozilla Firefox", | |
"userbrowserversion": "`date +%s`", | |
"referrer": "referrer-`date +%s`", | |
"requestargs": "requestargs-`date +%s`", | |
"postvalues": "postvalues-`date +%s`", | |
"errortype": "errortype-`date +%s`", | |
"errormsg": "errormsg-`date +%s`", | |
"when": "`date -u +"%Y-%m-%dT%H:%M:%S.00000"`", | |
"errortraceback": "errortraceback-`date +%s`", | |
"code": "code-`date +%s`", | |
"date": "`date -u +"%Y-%m-%dT%H:%M:%S.00000"`" | |
} | |
EOF | |
) | python -c "import sys, json; print(json.dumps(json.load(sys.stdin)))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run
To capture the result into a file named output.json