Skip to content

Instantly share code, notes, and snippets.

@khaliqgant
Created July 13, 2022 08:25
Show Gist options
  • Save khaliqgant/2c15dc351f9cfd338485da8919254af7 to your computer and use it in GitHub Desktop.
Save khaliqgant/2c15dc351f9cfd338485da8919254af7 to your computer and use it in GitHub Desktop.
[JQ Fallback Value] Fallback Value If Not Available #jq #cli
CPU_LIMIT=$(echo "$customer_line" | jq -r '.cpu_limits.foo // 0')
MEMORY_LIMIT=$(echo "$customer_line" | jq -r 'if has("memory_limits") then .memory_limits.foo else 0 end')
# https://stackoverflow.com/questions/56555155/get-or-default-function-in-jq/56555442#56555442
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment