I have two json files as below:
I wanna merge objects in tmp1.json and tmp2.json with InstanceId unique value in bash shell.
I have tried jq with argjson option but my jq 1.4 version not support this option. Sorry, I unable update jq to 1.5 version.
#cat tmp1.json
{
"VolumeId": "vol-046e0be08ac95095a",
"Instances": [
{
"InstanceId": "i-020ce1b2ad08fa6bd"
}
]
}
{
"VolumeId": "vol-007253a7d24c1c668",
"Instances": [
{
"InstanceId": "i-0c0650c15b099b993"
}
]
}
#cat tmp2.json
{
"InstanceId": "i-0c0650c15b099b993",
"InstanceName": "Test1"
}
{
"InstanceId": "i-020ce1b2ad08fa6bd",
"InstanceName": "Test"
}
My desired is:
{
"VolumeId": "vol-046e0be08ac95095a",
"Instances": [
{
"InstanceId": "i-020ce1b2ad08fa6bd"
"InstanceName": "Test"
}
]
}
{
"VolumeId": "vol-007253a7d24c1c668",
"Instances": [
{
"InstanceId": "i-0c0650c15b099b993"
"InstanceName": "Test1"
}
]
}