linux - Awk:- 如何处理 elb-describe-lbs 的文本以仅了解可用区

标签 linux bash amazon-web-services awk

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/

相关文章:

linux - 使用 select 系统调用阻止 recvfrom

c++ - 在 C++ 中解析 Protocol Buffer

linux - Telegram -cli : Script not sending message

amazon-web-services - boto CloudFormation BadRequest (400),异常 : None

web-services - 服务发现与负载均衡

python - 使用 python 和 wc -l 计算文件中的行数

linux - 环境变量不更新

bash - 带有终端后记的 gnuplot 线宽和线型

amazon-web-services - 部署 AWS Cloudformation LogGroup 时出错,但它仍然创建资源

linux - AWK 命令在 linux 中不起作用,但在 mac 中起作用