Created
October 17, 2015 04:43
-
-
Save sethc23/65ba1631484ec99ffa71 to your computer and use it in GitHub Desktop.
jq example of one-liner for generating JSON
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 | |
printf 'With Color:\n\n' | |
echo \ | |
'Producer: FOP 0.20.5 | |
Tagged: no | |
UserProperties: no | |
Suspects: no | |
Form: none | |
JavaScript: no | |
Pages: 2 | |
Encrypted: no | |
Page size: 648 x 857 pts | |
Page rot: 0 | |
File size: 9894 bytes | |
Optimized: no | |
PDF version: 1.3' | \ | |
jq -sRc 'splits("\n")? | split(":") as $i | { ($i[0]?) : ( $i[1] | sub("^(\\s)+"; ""; "x") ) }' | |
printf '\n\n\nWithout Color:\n\n' | |
echo \ | |
'Producer: FOP 0.20.5 | |
Tagged: no | |
UserProperties: no | |
Suspects: no | |
Form: none | |
JavaScript: no | |
Pages: 2 | |
Encrypted: no | |
Page size: 648 x 857 pts | |
Page rot: 0 | |
File size: 9894 bytes | |
Optimized: no | |
PDF version: 1.3' | \ | |
jq -sRcM 'splits("\n")? | split(":") as $i | { ($i[0]?) : ( $i[1] | sub("^(\\s)+"; ""; "x") ) }' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment