JSON файл следующим образом:
{
"ImageId": "ami-074acc26872f26463",
"KeyName": "Accesskeypair",
"SecurityGroupIds": ["sg-064caf9c470e4e8e6"],
"InstanceType": ""
"Placement": {
"AvailabilityZone": "us-east-1a"
}
}
чтение типа # вход от пользователя
Теперь я хочу добавить значение json в "InstanceType": "$ type" в файле, используя скрипт bash. Я пробовал sed, cat и 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
но когда я это делаю, появляется "InstanceType": "$ type" вместо "InstanceType": "t2.small"