Change the value of variable in a file

Hi Friends,

I have shell script file1.sh which has reference to enviornment file called

Content of filenev.sh

SKIP_FLAG=N
ORACLE_HOME=/u01/oracle/database

My requirement is to change the value of SKIP_FLAG to Y in filenv.sh from file1.sh. Could anyone please help me to do this.

After making the changes, content of fileenv.sh should like this:

SKIP_FLAG=Y
ORACLE_HOME=/u01/oracle/database

Thanks in advance.

Thanks,
Venkat

You could re-write the file with:-

grep -v "^SKIP_FLAG=" $environment_file > /tmp/env_file.tmp
(cat /tmp/env_file.tmp ; echo "SKIP_FLAG=Y" ) > $environment_file
rm /tmp/env_file.tmp

Does that help?

You could edit it with sed of vi too, such as:-

echo ":%s /^SKIP_FLAG=N/SKIP_FLAG=Y/\n:wq" | vi $environment_file >/dev/null

I hope that these give you a start.

Robin
Liverpool/Blackburn
UK

Thanks alot for quick help. It helped.

Thanks,
Venkat