When I run the following command, I expect to get the ip addresses of ASG member instances:
current_servers=$(aws ec2 describe-instances --instance-ids $(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names "${asgname}" --region $region | grep InstanceId | awk -F: '{print $2}' | tr -d '\"|,' | tr -d '\n') --region $region | grep "PrivateIpAddress" | grep -v '\[' | awk -F: '{print $2}' | uniq -u | tr -d '\"|,' )
For some reason, the I get no output.
But if I change the uniq -u
command to just uniq
, then I get the correct output.
From uniq's man:
-u, --unique
only print unique lines
Without the uniq command, the output is:
172.51.39.73
172.51.39.73
172.51.39.73
So it seems (by uniq's man) that if I want to get only one occurrence of the output I have to use uniq -u
.
Anyone knows why the command acts like that? that is giving me no output if I use the "-u" switch?