Link to home
Start Free TrialLog in
Avatar of mac_g
mac_gFlag for Saudi Arabia

asked on

shell script : find and replace using sed .. not reflecting when using parameters to sed


===== shell script tt.sh =============
var1="(CMANAGER_NAME = GOOGLE.WORLD))"
echo $var1

var2="(RAW_NAME = dest.com))"
echo $var2

find . -type f -name 2.txt -print0 | xargs -0   sed  -i 's@$var1@$var2@g'


========2.txt=================
hello1

(CMANAGER_NAME = GOOGLE.WORLD))

hello2

(RAW_NAME = dest.com))

hello3
================== ERROR MESSAGE
hello3[root@RHEL7 scripts]# sh tt.sh
(CMANAGER_NAME = GOOGLE.WORLD))
(RAW_NAME = dest.com))
sed: -e expression #1, char 16: unterminated `s' command
[root@RHEL7 scripts]#


Avatar of mac_g
mac_g
Flag of Saudi Arabia image

ASKER

please advice solution
SOLUTION
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mac_g

ASKER

Just one word  .. ..  
U save my Day@ simon3270User generated image 


Please advice for preparing server automation scripts, apart from shell scripting which other scripting will be helpful for unix based  env ??

=====================
I have tested below type of strings, that actually is my requirement .. working perfect


(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ngerard)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = orcl)))(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = other)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = orcl)))


(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP99)(HOST = other)(PORT = 1521-99)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = ORCL)))


ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mac_g

ASKER

problem solved