Json file as follows:
{
"ImageId": "ami-074acc26872f26463",
"KeyName": "Accesskeypair",
"SecurityGroupIds": ["sg-064caf9c470e4e8e6"],
"InstanceType": ""
"Placement": {
"AvailabilityZone": "us-east-1a"
}
}
read type #input from user
now i want to add json value in "InstanceType": "$type" in file using bash script i have tried sed, cat and echo
echo "Hello"
echo "lets create an instance"
echo "please enter the type of instance you need"
read instance_type;
echo $type
sed -a '|\InstanceType": "|$instance_type|a' awsspotinstancecreation.json
sed -e '/\"InstanceType": "|$instance_type|/a' awsspotinstancecreation.json
sed -i "/\InstanceType": "/ s/^\(.*\)\('\)/\1, $instance_type/" awsspotinstancecreation.json
sed -e 's/^"InstanceType": "",.*$/"InstanceType": "$instance_type",/g' awsspotinstancecreation.json
sed -i 's/^InstanceType .*$/"InstanceType": "$instance_type",/' awsspotinstancecreation.json
sed -i 's:^"InstanceType": "",.*$:"InstanceType": "$instance_type",:a' awsspotinstancecreation.json
but when I do it comes "InstanceType": "$type" instead of "InstanceType": "t2.small"