Now I want to change the value of the PROGRAM_NAME as SOME_PROGRAM_NAME_VERY_USEFUL.
That is, I want to append something to which is already existing using sed command.
This PROGRAM_NAME can be anywhere in that line, i.e., not in a specific field number.
And the value of the PROGRAM_NAME may vary depending on the server in which we are using.
$ sed "s/PROGRAM_NAME=[^)]*/PROGRAM_NAME=put what you want here/" file
VVV= jdbc: oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=XXXX))(ADDRESS=(PROTOCOL=TCP)(HOST=)(P ORT=XXXX))(LOAD_BALANCE=yes)(PROGRAM_NAME=put what you want here)(CONNECT_DATA=(SERVER=DEDICATED)))
is the original value.
But What I want exactly is,
The original value should be as same as before. But also some more content should be appended to it. So for that I hope it should recognize the first ) after PROGRAM_NAME=... and then append _VERY_USEFUL to that before that first occurance of the ).
And the value of the PROGRAM_NAME may vary depending on the server in which we are using.
Hope you got my question now.
Also I want to make the changes permanent in the modifying file.
Please help me...
Ah....That's So nice of you..It worked for me...
Can you also help me how can I insert a variable value or a command output into that....
Say for example, i want to append the output of the `dnsdomainname` command to the PROGRAM_NAME.
When I am trying for this, the $ value if variable, or the command name itself is being reflecting there...
sed "s/PROGRAM_NAME=[^)]*/&_$(dnsdomainname)/" file
(although, if I understand what you want, you already answered the question with `dnsdomainname`, but I prefer the $(...) notation over the back-quotes!)