Open jlevy opened 7 years ago
Suggestions or ideas welcome — comment here! :)
I suppose this falls outside of the strict definition of "one-liner", but it works rather nicely for displaying the number of AZs for a given region (also depends on jq being installed):
echo -e "$(tput bold)Region | # AZs$(tput sgr0)";for region in $(aws ec2 describe-regions | jq -r '.Regions[].RegionName'); do
num_azs=$(aws ec2 describe-availability-zones --region ${region} | jq -r '.AvailabilityZones | length')
printf '%-15s | %5s\n' ${region} ${num_azs}
done
Good quick one for grabbing the state of creation of an AMI (usually use in some kind of while loop):
aws ec2 describe-images --owners "self" --region ${region} | jq -cr ".Images[] | select(.ImageId | contains(\"${ami_id}\")) | .State"
Either of those ^ work nicely as a function in your .bashrc
/.zshrc
- happy to provide the extra wrapping code if desired.
Thanks @geekmuse ! Want to get some more examples and we'll somehow get them in.
Although the use case for these one-liners are for bioinformatics, here's a good list to borrow from https://github.com/stephenturner/oneliners
We should have a few more judiciously chosen examples in https://github.com/jlevy/the-art-of-command-line#one-liners
The examples should be nontrivial (to make you think or look stuff up), useful (not just entertainment), illustrative/interesting (will make sense to a lot of people), not overtly encouraging bad behavior (obfuscations or error-prone habits), and each one a little different from the others.