Hi,
I am trying to replace a string in shell but it is not working correctly.
@xcom.file@
needs to be replaced with
tb137
Plz help.Thx.
Hi,
I am trying to replace a string in shell but it is not working correctly.
@xcom.file@
needs to be replaced with
tb137
Plz help.Thx.
sed 's/@xcom.file@/tb137/g' infile
If you use bash, you could also do something like this:
$> VAR="1234@xcom.file@5678@xcom.file@90"
$> echo ${VAR//@xcom.file@/tb137}
1234tb1375678tb13790
Thanks for the response
Need more modifications though.
file1:
RECLASS:@xcom.reclass.hostname@:REMOTE_SYSTEM=@xcom.reclass.remote_system@
This needs to be replaced with value of variables declared in file2:
input.xcom.reclass.hostname=tb1234
input.xcom.reclass.remote_system=tbj1234545
desired op:file1 should be:
RECLASS:tb1234:REMOTE_SYSTEM=tbj1234545
awk 'NR==FNR{gsub(/input./,""); split($0,a,"=");b[a[1]]=a[2];next} {gsub(/@/,"");for (i in b) gsub(i,b)}1' file2 file1
Appreciate your help!It works..Just that the output of awk operation is coming in a single line.From the man page of awk,I realized that gsub,split don't recognize new line characters. Is there any way that the op can be in this format?
File 1:
input.xcom.range.hostname = DUMMY
input.xcom.range.remote_system = DUMMY
input.xcom.range.userid = DUMMY
input.xcom.range.password = DUMMY
input.xcom.range.remote_file_system = DUMMY
input.xcom.reclass.hostname = tb137
input.xcom.reclass.remote_system = DUMMY
input.xcom.reclass.userid = DUMMY
input.xcom.reclass.password = DUMMY
input.xcom.reclass.remote_file_system = DUMMY
File 2:
RANGE:@xcom.range.hostname@:REMOTE_SYSTEM=@xcom.range.remote_system@ USERID=@xcom.range.password@ PASSWORD=@xcom.reclass.password@:REMOTE_FILE=@xcom.range.remote_file_system @:
RECLASS:@xcom.reclass.hostname@:REMOTE_SYSTEM=@xcom.reclass.remote_system@ USERID=@xcom.reclass.userid@ PASSWORD=@xcom.reclass.password@:REMOTE_FILE==@xcom.reclass.remote_file_system@:
Desired op is:file 2 should be:
RANGE:DUMMY:REMOTE_SYSTEM=DUMMY USERID=DUMMY PASSWORD=DUMMY:REMOTE_FILE=DUMMY:
RECLASS:tb137:REMOTE_SYSTEM=DUMMY USERID=DUMMY PASSWORD=DUMMY:REMOTE_FILE=DUMMY:
After running the command now,it comes in a single line.
RANGE:DUMMY:REMOTE_SYSTEM=DUMMY USERID=DUMMY PASSWORD=DUMMY:REMOTE_FILE=DUMY:RECLASS:tb137:REMOTE_SYSTEM=DUMMY USERID=DUMMY PASSWORD=DUMMY:REMOTE_FILE=DUMMY: