Reputation: 4511
I am using the Amazon Cli tools
to write an ec2 audit script
.I want to fetch the tags like name, owner, cost centre
from the ec2-describe-instances
.
I am using this command :
ec2-describe-instances | grep -i "tag" | grep -i -e "name" -e "owner" -e "cost.centre"
please help
Upvotes: 0
Views: 211
Reputation: 77135
You can pipe your existing command to awk
for formatting ...
ec2-describe-instances | grep -i "tag" | grep -i -e "name" -e "owner" -e "cost.centre" | awk 'BEGIN{FS=OFS="\t"}{a[$1 FS $2 FS $3]=a[$1 FS $2 FS $3]?a[$1FS$2FS$3] FS $4 FS $5:$4 FS $5}END{for(x in a) print x, a[x]}'
Upvotes: 1