I need to use sed to modify the 3rd line in my.json file as line shown below.
How do I replace a changing key value( this example shows "group-1") with the variable value that is assigned to $username?
"name": "group-1",
You can replace like below
Linux
sed -i 's/\"name\":.*/\"name\": '${username}'/g' "/path/to/my.json"
MacOS
sed -i "" 's/\"name\":.*/\"name\": '${username}'/g' "/path/to/my.json"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With