from this aws config file below, I want to replace the aws region only in default section:
[proj1]
output = json
region = aws_region
[default]
output = json
region = us-east-1
[proj2]
output = json
region = us-east-1
[proj2-frankfurt]
output = json
region = eu-central-1
from this command, I reach to retrieve the line number position of [default] section:
grep -n "default" ~/.aws/config | awk -F ":" '{print $1}'
the result is: 5 (as expected)
so, from this output (line number), I want to replace with sed the (only) first occurrence instead of "aws_region" by "eu-central-1" for example by doing something like that:
sed -i '7,/aws_region/s//eu-central-1/' ~/.aws/config
where 7 is my output from the previous command
How to do this in one operation?