PhillyG wrote:
I thought there was a way to use c in command mode; I can't find it.
What do you mean? What are you trying to achieve?
In input mode, your input is written to the file ; you can't use commands.
PhillyG wrote:
Now I need to figure out how to replace NEW_KEY NEW_VALUE with a string variable.
I should replace CURRENT_KEY with a variable as well.
Use
printf(0).
Code:
printf '%s\n' "g/${current_key}/" c "$new_key"$'\t\t'"$new_value" . w | ed -s "$parameter_file"
PhillyG wrote:
How do I create a script that includes the above?
Code:
#!/bin/sh
...
> /dev/null ed -s "$parameter_file" << EOE
g/${current_key}/
c
$new_key $new_value
.
w
EOE