我有这个json输出
{
"FileSystems": [
{
"CreationToken": "CreationToken1",
"OwnerId": "OwnerId1",
"SizeInBytes": {
"Timestamp": 1552377599.0,
"Value": 1550721024
},
"Name": "Name1",
"NumberOfMountTargets": 3,
"FileSystemId": "fs-1",
"LifeCycleState": "available",
"CreationTime": 1550506468.0,
"PerformanceMode": "generalPurpose"
},
{
"CreationToken": "CreationToken2",
"OwnerId": "OwnerId2",
"SizeInBytes": {
"Timestamp": 1552377599.0,
"Value": 2390339584
},
"Name": "Name2",
"NumberOfMountTargets": 3,
"FileSystemId": "fs-2",
"LifeCycleState": "available",
"CreationTime": 1547663741.0,
"PerformanceMode": "generalPurpose"
}
]
}
使用此命令
aws efs describe-file-systems | jq -r ".FileSystems[] | .SizeInBytes.Value"
我可以接收NFS大小的值:
1550725120
2390339584
但是我需要获得带有文件系统名称的输出,所以应该像这样:
Name1: 1550725120
Name2: 2390339584
我该怎么办?
答案 0 :(得分:1)
您可以使用string interpolation,如下所示:
jq -r ".FileSystems[] | \"\(.Name) \(.SizeInBytes.Value)\""