New to scripting.. think i need sed to do the following but need help.
have a properties files with variable i need to replace using substitution
for e.g in x.properties
xslt.root.dir=/apps1/test/cs.war/presentation/xsl
have a shell script with following
echo "Edit '/tmp/x.properties'"
echo "-----------------------------------------------------------------------------"
echo "Modify 'xslt.root.dir=' with the environment specific path"
echo "xslt.root.dir=$PWD/presentation/xsl"
echo ""
(need command here to replace xslt.root.dir= variable in x.properties with either a variable read in from command line or $PWD variable)
echo "Press [Enter] when file has been modified"
read $ANS
echo ""
echo "Edit '/tmp/leena/web.xml'"
echo "-----------------------------------------------------------------------------"
echo "Modify '/apps1/instance_t05/edi/fatwire' with the environment specific path"
echo "$PWD"
echo ""
echo "Press [Enter] when file has been modified"
read $ANS
echo ""
have a properties files with variables i need to replace using substitution in a shell script
for e.g in
x.properties
xslt.root.dir=/apps1/test/cs.war/presentation/xsl
have a shell script with following
echo "Edit '/tmp/x.properties'"
echo "-----------------------------------------------------------------------------"
echo "Modify 'xslt.root.dir=' with the environment specific path"
echo "xslt.root.dir=$PWD/presentation/xsl"
echo ""
(need command here to replace xslt.root.dir= variable in x.properties with either a variable read in from command line or $PWD variable)
echo "Press [Enter] when file has been modified"
read $ANS
echo ""
echo "Edit '/tmp/leena/web.xml'"
echo "-----------------------------------------------------------------------------"
echo "Modify '/apps1/instance_t05/edi/fatwire' with the environment specific path"
echo "$PWD"
echo ""
echo "Press [Enter] when file has been modified"
read $ANS
echo ""
http://www.unix.com/images/misc/progress.gif
I'm still extremely new to sed and all this, but I did a test and it replaced the one thing you needed replaced. But i'm sure there is a better shorter way to do this:
sed -i "s:xslt.root.dir=.*:xslt.root.dir=$PWD/presentation/xsl:" test2
test2 is the name of the file, so if you can easily do this to multiple files if needed.