replace a character with another character

hi
i have a string var=abc.ghi.jkl.mno.pqr
now i need to replace .(dot) with _(underscore)
the result should be like "arresult=abc_def_ghi_jkl_mno_pqr"

Please help

echo $var | sed 's/\./_/g' -> will print the variable

x=`echo $var | sed 's/\./_/g'` will get the output into x variable.

echo $var|sed 's/\./\_/g'

echo 'abc.ghi.jkl.mno.pqr' | tr '.' '_'

If you are using bash or ksh93

$ var=abc.ghi.jkl.mno.pqr
$ result=${var//./_}
$ echo $result
abc_ghi_jkl_mno_pqr

hi,

I want to replace _ with \.
I am using below command.
echo old_path | sed 's/\_/\\
/g'

It is working fine.
but when I use that in script file like below.
$oldpath1=`echo old_path | sed 's/\_/\\_/g' > 1`;
$ echo oldpath1
oldpath1

It is not repacing.
Any suggestions.

Thanx in advance.

oh sorry.
I mean to say.
$ echo $oldpath1

oldpath1 is null.

echo 'a/b_c/d_e_f/g' | sed 's#_#\\&#g'
$
$ x=`echo 'a/b_c/d_e_f/g' | sed 's/\_/\\\_/g'`
$
$ echo $x
a/b\_c/d\_e\_f/g
$
$

tyler_durden