Skip to content

Instantly share code, notes, and snippets.

@fent
Last active January 8, 2018 04:06
Show Gist options
  • Save fent/7807602 to your computer and use it in GitHub Desktop.
Save fent/7807602 to your computer and use it in GitHub Desktop.
Returns a list of servers matching a pattern.
#!/bin/bash
h=$1
if [ -z $1 ]
then
echo "Usage: `basename $0` <host pattern>"
exit 1
fi
ec2-host | grep $h | awk '{split($0, a, "\t"); print a[2]}' | awk '{x = (!x) ? $0 : x "\n" $0;} END {print x;}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment