-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Bash redirection malforms output with single instance EC2 regions #2493
Copy link
Copy link
Closed
Labels
closing-soonThis issue will automatically close in 4 days unless further comments are made.This issue will automatically close in 4 days unless further comments are made.guidanceQuestion that needs advice or information.Question that needs advice or information.
Description
I'm using a loop to list some information from all the instances across all zones:
#/bin/bash
for region in $(aws ec2 describe-regions --output text | cut -f3)
do
echo "##### $region ######"; aws ec2 describe-instances --query 'Reservations[*].Instances[*].[{Name:[Tags[?Key==`Name`].Value][0][0],Service:[Tags[?Key==`service`].Value][0][0],LocalIP:PrivateIpAddress,PublicIP:PublicIpAddress,Owner:[Tags[?Key==`owner`].Value][0][0],PrivateDNS:PrivateDnsName,RunningState:State.Name,AvailabilityZone:Placement.AvailabilityZone}]' --output table --region $region
done
The output is expected for all zones, but when I use bash redirect (either > or &> or 2&1> or even tee) it is malformed for zones that have single instances. I've created a few EC2 instances to test it and it really does seem to be connected to the number of servers in a region. More than one and the table is looking wrong, but again, only when using redirects.
JSON and text works fine.
aws-cli/1.10.49 Python/2.7.10 Linux/4.2.0-16-generic botocore/1.4.39
Ubuntu 15.10
GNU Bash 4.3.42
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
closing-soonThis issue will automatically close in 4 days unless further comments are made.This issue will automatically close in 4 days unless further comments are made.guidanceQuestion that needs advice or information.Question that needs advice or information.