Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 527

export json output to environment variable missing commas in Bash

$
0
0
[{"Availab]ilityZone": "ap-east-1a" "Description": "AWS_FOO" "Groups": [    {"GroupName": "AWS_FOO" "GroupId": "sg-AWS_FOO"    }     {"GroupName": "AWS_FOO" "GroupId": "sg-AWS_FOO"    }  ]  } {"Availab]ilityZone": "ap-east-1a" "Description": "AWAWS_FOOAWS_FOO" "Groups": [    {"GroupName": "AWS_FOO-eAWS_FOOAWS_FOO" "GroupId": "sAWS_FOO"    }     {"GroupName": "AWS_FOO" "GroupId": "AWS_FOO"    }  ] }]

I am tring to write a automation script that required to use aws cli to find the values,

NETWORK_INTERFACE=$(aws ec2 describe-network-interfaces --filters Name=vpc-id,Values="${VPC_ID}" --output json | jq -r '.NetworkInterfaces[]')

However, when I echo $NETWORK_INTERFACEthe,the output will missing all commas "," , make it not a valid json format and cannot use jq to further action

I tried using IFS, sed but the result is not what I expected

My expected output is valid json like

[{"Availab]ilityZone": "ap-east-1a","Description": "AWS_FOO" ,"Groups": [    {"GroupName": "AWS_FOO" ,"GroupId": "sg-AWS_FOO",    } ,    {"GroupName": "AWS_FOO" ,"GroupId": "sg-AWS_FOO",    }  ] }, {"Availab]ilityZone": "ap-east-1a","Description": "AWAWS_FOOAWS_FOO","Groups": [    {"GroupName": "AWS_FOO-eAWS_FOOAWS_FOO","GroupId": "sAWS_FOO",    },    {"GroupName": "AWS_FOO","GroupId": "AWS_FOO",    }  ] }]

Viewing all articles
Browse latest Browse all 527

Trending Articles