/ Bash

Parsing environment variables with JQ

JQ provides this nifty env input that enables you to reference environment variables using the JQ style query syntax.

# prints all envs in JSON format
jq -n env

And you can use piping like you would with a normal JSON input.

# print $HOME in raw format
jq -nr 'env | .HOME'