elb-descibe-lbs 的典型长 View 输出如下:-
Prompt:- elb-describe-lbs --region xxxxx --headers --lbs xxxxxx --show- long view
LOAD_BALANCER,NAME,DNS_NAME,CANONICAL_HOSTED_ZONE_NAME,CANONICAL_HOSTED_ZONE_NAME_ID,HEALTH_CH ECK,AVAILABILITY_ZONES,SUBNETS,VPC_ID,INSTANCE_ID,LISTENER_DESCRIPTIONS,BACKEND_SERVER_DESCRIP TIONS,SOURCE_SECURITY_GROUP,SECURITY_GROUPS,CREATED_TIME,SCHEME
LOAD_BALANCER,xxxxxx,xxxxx.xxxxxx.elb.amazonaws.com,xxx- xxxxx-xxxx-xxxxxx.xx-xxxx-x.elb.amazonaws.com,xxxxxxx," {interval=xx,target=HTTP:xx/index.html,timeout=5,healthy-threshold=xx,unhealthy-threshold=xx}","eu-west-1b, eu-west-1a",(nil),(nil),"xxxxxx","
我只想获取可用区信息,所以我将 awk 用作:-
elb-describe-lbs --region xxxxx --headers --lbs xxxxx --show-long view | awk -F, 'NR {print $7}'
输出为:-
AVAILABILITY_ZONES
target=HTTP:xx/index.html
不过,我想在其标题下方获取可用区信息,但由于分隔符为“逗号”,它在 awk 的 feild $11 中出现。
例如:-
elb-describe-lbs --region eu-west-1 --headers --lbs scc-emeaprod-tw --show-long view | awk -F, 'NR {print $7,$11,$12}'
输出是
AVAILABILITY_ZONES LISTENER_DESCRIPTIONS BACKEND_SERVER_DESCRIPTIONS
target=HTTP:xx/index.html "eu-west-1b eu-west-1a"
如何在此处操作第 1 列和第 2 列的文本,以便在其标题下方获得可用区
.
最佳答案
我会迁移旧的 CLI 并尝试新的 AWS CLI ( http://aws.amazon.com/cli/ )
aws elb describe-load-balancers --load-balancer-names awseb-e-i-AWSEBLoa-12*****0U --region us-east-1 --query "LoadBalancerDescriptions[].AvailabilityZones []"--输出文本
关于linux - Awk:- 如何处理 elb-describe-lbs 的文本以仅了解可用区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22707829/