How can i update the particular entry with appropriate values in a given file,
Let say i have a file name hello.conf,
/agent/process="starthelloJava",start="/opt/starthello.sh",start_dir="/opt/hello",start_args=""
/agent/process="stophelloJava",stop="/opt/stophello.sh",stop_dir=/opt/hello",stop_args="",stop_timeout="30"
update the starthelloJava with
start_args="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/"
output
/agent/process="starthelloJava",start="/opt/starthello.sh",start_dir="/opt/hello",start_args="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/"
empty the start_args of process starthelloJava
/agent/process="starthelloJava",start="/opt/starthello.sh",start_dir="/opt/hello",start_args=""
/agent/process="stophelloJava",stop="/opt/stophello.sh",stop_dir=/opt/hello",stop_args="",stop_timeout="30"
The way i’m doing is long step’s i’m rewriting the entire file, based on the input.
This is my apprach which is not efficient
cp hello.conf hello.conf_bak
remove entry first
cat /opt/CSCObac/agent/conf/agent.conf_bak | grep -v /opt/starthello.sh > hello.conf
echo "/agent/process=\"starthelloJava\",start=\"/opt/starthello.sh\",start_dir=\"/opt/hello\",start_args=\"-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/\" >> hello.conf
or to empty the value