yesmani
1
Hi,
I have a file1 as :
A=/home/user
B=/home/user1
C=/home/user2
D=/home/aacsms
E=/home/user1/temp
F=/home/user1/area1
and my script as:
a=`cat /home/aacsms7/file1 | grep -i e`
b=`user2`
sed 's/'$a'/"E=/home/'$b'/temp"/g' < file1 > file2
sed: command garbled: s/A=/home/user
I am trying to replace value of "E" in file1 as "E=/home/user2/temp" and write it in file2.
Please suggest wher am i wrong or will sed able to handle "/" in the pattern...
sed is very versatile you can you other char separator
root@server # grep \^E file | sed 'sXuser1Xuser2X'
E=/home/user2/temp
yesmani
3
Thanks for your response,,
i have one other complication, the file is too big and will be updated frequently, so sometimes i would not know what the is the value of E.
say E=/home/user1/temp
i tried your way earlier but that doest work for this scenario. sorry i dint mention that in my previous post.
you can assign it to variable
-bash-3.2$ var1=user1
-bash-3.2$ var2=user2
-bash-3.2$ echo 'E=/home/user1/temp' | sed "s|$var1|$var2|"
E=/home/user2/temp