I am using chef recipes for setting java_home. For that i am using sed command for finding JAVA_HOME string in bash_profile and then going to replace that line with
export JAVA_HOME="a/b/java"
so how to replace that line with sed command.
I am using chef recipes for setting java_home. For that i am using sed command for finding JAVA_HOME string in bash_profile and then going to replace that line with
export JAVA_HOME="a/b/java"
so how to replace that line with sed command.
This should work whether or not JAVA_HOME
is found
sed -i '/JAVA_HOME/d;$aexport JAVA_HOME="a/b/java"' .bash_profile
Another sed
,
sed -i.bak '/JAVA_HOME/s@.*@export JAVA_HOME="a/b/java"@' .bashrc