I have a text file with lines like this:
variable_name : value
I need to make a bash script to replace “value” with a fixed value I know (let say “myvalue”).
I don’t know previously which is the variable_name’s value.
I need to use bash commands that can be used in any default installation of linux box like sed, grep, awk, etc.
I know how to do it with sed when I know the “value” string, but I can’t figure out how to do it by searching in the file by the name of the variable.
EDIT: I add some complexity to this task, I have to exclude some patterns with a fixed text, for example if I have:
variable_name : value
variable_name : VARIABLE_NAME > lorem_ipsum
I have to exclude the replacement with the string VARIABLE_NAME. The result must be:
variable_name : myvalue
variable_name : VARIABLE_NAME > lorem_ipsum
Thanks in advance,
are you looking for this?
EDIT for new requirement
you said you will exclude replacement with string VARIABLE_NAME, so I assume that
(space)> lorem_ipsumwill be replaced by new value.so this line may help:
take a look this:
EDIT2
Neuquino, you should explain your requirement more clear….. anyway: