Created
May 30, 2018 22:28
-
-
Save moziauddin/bda6f3986bac55459e8d5bb8392923c5 to your computer and use it in GitHub Desktop.
JQ
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
aws ec2 describe-snapshots --owner-id 194924002687 | jq | |
499 aws ec2 describe-snapshots --owner-id 194924002687 | jq > /tmp/mo-sample.json | |
500 aws ec2 describe-snapshots --owner-id 194924002687 | jq . > /tmp/mo-sample.json | |
501 aws ec2 describe-snapshots --owner-id 194924002687 | jq '.' > /tmp/mo-sample.json | |
502 less /tmp/mo-sample.json | |
503 less /tmp/mo-sample.json | jq '.Snapshots' | |
504 less /tmp/mo-sample.json | jq '.Snapshots | length' | |
505 less /tmp/mo-sample.json | jq '.Snapshots' | less | |
506 less /tmp/mo-sample.json | jq '.' | less | |
507 less /tmp/mo-sample.json | jq '.Snapshots[0]' | |
508 clear | |
509 less /tmp/mo-sample.json | jq '.Snapshots[0]' | |
510 less /tmp/mo-sample.json | jq '.Snapshots' | |
511 less /tmp/mo-sample.json | jq '.Snapshots | sort_by(Description)' | |
512 less /tmp/mo-sample.json | jq '.Snapshots | sort_by(.Description)' | |
513 less /tmp/mo-sample.json | jq '.Snapshots | sort_by(.Description)' |less | |
514 aws ec2 describe-snapshots --help | |
515 aws ec2 describe-snapshots help | |
516 less /tmp/mo-sample.json | |
517 less /tmp/mo-sample.json | jq '[ .Snapshots[] | {Description,SnapshotId,VolumeId} ] | |
518 less /tmp/mo-sample.json | jq '[ .Snapshots[] | {Description,SnapshotId,VolumeId} ]' | |
519 less /tmp/mo-sample.json | jq '[ .Snapshots[] | {Description,SnapshotId,VolumeId} ]' | less | |
520 less /tmp/mo-sample.json | jq '[ .Snapshots[] | {Description,SnapshotId,VolumeId,Tags} ]' | less | |
521 less /tmp/mo-sample.json | jq '[ .Snapshots[] | .Tags' | |
522 less /tmp/mo-sample.json | jq '[ .Snapshots[] | .Tags ]' | |
523 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags end ]' | |
524 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags then .Tags end ]' | |
525 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags then .Tags else [] end ]' | |
526 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags then .Tags else end ]' | |
527 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags then .Tags else ; end ]' | |
528 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags then .Tags else | end ]' | |
529 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags then .Tags else "fuck" end ]' | |
530 less /tmp/mo-sample.json | jq '[ .Snapshots[] | if .Tags then .Tags else "" end ]' | |
531 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags ' | |
532 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[] | ' | |
533 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[] | "fuck"' | |
534 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[{InstanceId}] ' | |
535 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[].InstanceId ' | |
536 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[]|.InstanceId ' | |
537 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[]|.Key ' | |
538 less /tmp/mo-sample.json | jq '.Snapshots[0] | if .Tags[]|.Key ' | |
539 less /tmp/mo-sample.json | jq '.Snapshots[0] | select(.Key == "InstanceId") ' | |
540 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[] ' | |
541 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[] | select(.Key == "InstanceId")' | |
542 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[] | select(.Key == "InstanceId") | {"InstanceId": .}' | |
543 less /tmp/mo-sample.json | jq '.Snapshots[0] | .Tags[] | select(.Key == "InstanceId") | {"InstanceId": .Value}' | |
544 less /tmp/mo-sample.json | jq 'def extract_tags(t): t | select(.Key == "InstanceId") | {"InstanceId": .Value}; .Snapshots[0] | extract_tags(.Tags)' | |
545 less /tmp/mo-sample.json | jq 'def extract_tags(t): t | select(.Key == "InstanceId") | {"InstanceId": .Value}; .Snapshots[0] | extract_tags(.Tags[])' | |
546 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t | select(.Key == "InstanceId") | {"InstanceId": .Value}; .Snapshots[0] | extract_instance_id(.Tags[])' | |
547 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t[] | select(.Key == "InstanceId") | {"InstanceId": .Value}; .Snapshots[0] | extract_instance_id(.Tags)' | |
548 less /tmp/mo-sample.json | jq '[ .Snapshots[0] | {Description,SnapshotId,VolumeId} ]' | |
549 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t[] | select(.Key == "InstanceId") | {"InstanceId": .Value}; [ .Snapshots[0] | {Description,SnapshotId,VolumeId} ]' | |
550 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t[] | select(.Key == "InstanceId") | {"InstanceId": .Value}; [ .Snapshots[0] | {Description,SnapshotId,VolumeId,extract_instance_id(Tags)} ]' | |
551 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t[] | select(.Key == "InstanceId") | {"InstanceId": .Value}; .Snapshots[0] | extract_instance_id(.Tags)' | |
552 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t[] | select(.Key == "InstanceId") |.Value; .Snapshots[0] | extract_instance_id(.Tags)' | |
553 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t[] | select(.Key == "InstanceId") |.Value; .Snapshots[0] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)}' | |
554 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): t[] | select(.Key == "InstanceId") |.Value; [ .Snapshots[] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)} ]' | |
555 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then t[] | select(.Key == "InstanceId") |.Value else null end; [ .Snapshots[] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)} ]' | |
556 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then t[] | select(.Key == "InstanceId") |.Value else null end; [ .Snapshots[] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)} ]' |less | |
557 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then t[] | select(.Key == "InstanceId") |.Value else null end; [ .Snapshots[] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)} ]|length' | |
558 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then t[] | select(.Key == "InstanceId") |.Value else null end; [ .Snapshots | length ]' | |
559 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then t[] | select(.Key == "InstanceId") |.Value else null end; [ .Snapshots[] | {Description, SnapshotId, VolumeId} ]|length' | |
560 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then t[] | select(.Key == "InstanceId") |.Value else "fuck" end; [ .Snapshots[] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)} ]|length' | |
561 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then (t[] | select(.Key == "InstanceId") |.Value) else null end; [ .Snapshots[] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)} ]|length' | |
562 less /tmp/mo-sample.json | jq 'def extract_instance_id(t): if t then (t[] | if select(.Key == "InstanceId") then . else null end |.Value) else null end; [ .Snapshots[] | {Description, SnapshotId, VolumeId, "InstanceId":extract_instance_id(.Tags)} ]|length' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment