Last active
June 17, 2018 10:14
-
-
Save cboddy/d5c38348a2ae07bcf8f1348b6a54813d to your computer and use it in GitHub Desktop.
A bash function to pretty print a file or cbor-encoded data.
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 | |
# | |
# add to ~/.bashrc or similar | |
# | |
# usage: | |
# | |
# > cbor_print /path/to/my/file.cbor | |
function cbor_print() { | |
# pretty print the contents of a file of cbor-encoded data | |
if python -c 'import cbor'; then | |
python -c "import cbor; from pprint import pprint; pprint((cbor.load(open('$1'))))"; | |
else | |
echo "Error: requires the python cbor package eg." | |
echo " pip install cbor" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment