I\'m launching an EC2 instance, by invoking ec2-run-instances from simple a bash script, and want to perform further operations on that instance (e.g. associate elastic IP)
No need to use awk:
# create the instance and capture the instance id
echo "Launching instance..."
instanceid=$(ec2-run-instances --key $pemkeypair --availability-zone $avzone $ami | egrep ^INSTANCE | cut -f2)
if [ -z "$instanceid" ]; then
echo "ERROR: could not create instance";
exit;
else
echo "Launched with instanceid=$instanceid"
fi
from http://www.hulen.com/post/22802124410/unattended-amazon-ec2-install-script