linux:jq
                Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| linux:jq [20/02/2024 17:01] – created - external edit 127.0.0.1 | linux:jq [28/05/2025 09:30] (current) – [jq - json parser] andrew | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| jq tutorial:- [[https:// | jq tutorial:- [[https:// | ||
| + | |||
| + | See also [[bash-json|Embedding a BASH variable in JSON]] | ||
| ====== AWS Policy - get ARN ====== | ====== AWS Policy - get ARN ====== | ||
| Line 57: | Line 59: | ||
| SecretSession== | SecretSession== | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ====== Extracting multiple values in one pass ====== | ||
| + | |||
| + | Use a comma to separate multiple fields to extract:- | ||
| + | |||
| + | Raw outpput for NAT gateways | ||
| + | <code json> | ||
| + | $ aws ec2 describe-nat-gateways | ||
| + | { | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ], | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Code to extract just NAT id, state and Elastic ip in use:- | ||
| + | <code bash> | ||
| + | $ aws ec2 describe-nat-gateways | jq " | ||
| + | |||
| + | " | ||
| + | " | ||
| + | " | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
linux/jq.1708448465.txt.gz · Last modified:  by 127.0.0.1
                
                