Skip to content

Instantly share code, notes, and snippets.

@hkupty
Created December 3, 2021 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkupty/a1f2073085bdb4c56caaad3cd96620cd to your computer and use it in GitHub Desktop.
Save hkupty/a1f2073085bdb4c56caaad3cd96620cd to your computer and use it in GitHub Desktop.
bash function to extract json values, either using stdin or argument
function x_json() {
jq -creM "${1}" <([ -z ${2+x} ] && cat - || echo "${2}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment