我的 cli 输出如下,
GROUP DEFINITIONS SERVICE DIMENSION
RESULTSBYTIME False
KEYS AWS CloudShell
BLENDEDCOST 0.0000026589 USD
KEYS AWS CloudTrail
BLENDEDCOST 0.000001 USD
KEYS AWS Config
BLENDEDCOST 46.921 USD
KEYS AWS Glue
BLENDEDCOST 355.70735552 USD
KEYS AWS Key Management Service
BLENDEDCOST 0.10418545 USD
KEYS AWS Lambda
BLENDEDCOST 0.0000002605 USD
KEYS AWS Migration Hub Refactor Spaces
BLENDEDCOST 0 USD
KEYS AWS Secrets Manager
BLENDEDCOST 2.0496788951 USD
KEYS AWS Security Hub
BLENDEDCOST 0.028892556 USD
KEYS AWS Service Catalog
BLENDEDCOST 0 USD
KEYS AWS Step Functions
BLENDEDCOST 0.0000000031 USD
KEYS AWS Support (Business)
BLENDEDCOST 246.2376324993 USD
KEYS AWS Systems Manager
BLENDEDCOST 0.000351 USD
KEYS AWS Transfer Family
BLENDEDCOST 208.8 USD
KEYS Amazon EC2 Container Registry (ECR)
BLENDEDCOST 0.2636971622 USD
KEYS EC2 - Other
BLENDEDCOST 325.4630384796 USD
KEYS Amazon Elastic Compute Cloud - Compute
BLENDEDCOST 694.4962624953 USD
KEYS Amazon Elastic Container Service for Kubernetes
BLENDEDCOST 69.890509083 USD
KEYS Amazon Elastic File System
BLENDEDCOST 0.0000002652 USD
KEYS Amazon Elastic Load Balancing
BLENDEDCOST 73.2040001769 USD
我期望输出如下,BLENDEDCOST 重复项应该被删除,并且 KEYS 应该出现在新行中。将行转换为列并删除重复项?
AWS CloudShell 0.0000026589 USD
AWS CloudTrail 0.000001 USD
AWS Config 46.921 USD
AWS Glue 355.7073555 USD
AWS Key Management Service 0.10418545 USD
AWS Lambda 0.0000002605 USD
AWS Migration Hub Refactor Spaces 0 USD
AWS Secrets Manager 2.049678895 USD
AWS Security Hub 0.028892556 USD
AWS Service Catalog 0 USD
AWS Step Functions 0.0000000031 USD
AWS Support (Business) 246.2376325 USD
AWS Systems Manager 0.000351 USD
AWS Transfer Family 208.8 USD
Amazon EC2 Container Registry (ECR) 0.2636971622 USD
EC2 - Other 325.4630385 USD
Amazon Elastic Compute Cloud - Compute 694.4962625 USD
Amazon Elastic Container Service for Kubernetes 69.89050908 USD
Amazon Elastic File System 0.0000002652 USD
Amazon Elastic Load Balancing 73.20400018 USD
Amazon Elastic MapReduce 2.28898852 USD
Amazon Glacier 0.0000000025 USD
Amazon GuardDuty 7.367077065 USD
Amazon Inspector 1 USD
Amazon Location Service 0 USD
Amazon Relational Database Service 388.1651428 USD
Amazon Route 53 0.508976 USD
Amazon Simple Notification Service 0.2022960904 USD
Amazon Simple Queue Service 0 USD
Amazon Simple Storage Service 3.338266835 USD
Amazon Simple Workflow Service 0.0000000015 USD
Amazon Virtual Private Cloud 147.4110373 USD
AmazonCloudWatch 60.12971039 USD
CloudWatch Events 0.000048 USD
CodeBuild 29.71339194 USD
使用 GNU
sed
:或
perl
:为了匹配您的输出,您需要将“混合成本”添加到标题并删除第二行,然后删除
USD
例如管道输出到:总共:
输出:
非常简单的替代方案,其输出应该相当容易修复:
与
pcregrep
:或者使用标准
sed
:(不处理重复项,因为从您的描述中不清楚它们会是什么样子)。