![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| replace first character of string sed | prkfriryce | Shell Programming and Scripting | 6 | 08-03-2007 11:07 AM |
| Replace a character in last line | Mohammed | Shell Programming and Scripting | 6 | 08-01-2007 11:46 AM |
| How to replace a character in a file | preethgideon | Shell Programming and Scripting | 6 | 08-30-2006 03:19 PM |
| replace character with tr | tmxps | UNIX for Dummies Questions & Answers | 3 | 09-29-2005 04:32 AM |
| Help to replace character strings | rahulrathod | UNIX for Dummies Questions & Answers | 4 | 09-27-2004 07:08 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
try this
echo $var | sed 's/\./_/g' -> will print the variable
x=`echo $var | sed 's/\./_/g'` will get the output into x variable. |
|
#3
|
|||
|
|||
|
echo $var|sed 's/\./\_/g'
|
|
#4
|
|||
|
|||
|
Code:
echo 'abc.ghi.jkl.mno.pqr' | tr '.' '_' |
|
#5
|
|||
|
|||
|
If you are using bash or ksh93
Code:
$ var=abc.ghi.jkl.mno.pqr
$ result=${var//./_}
$ echo $result
abc_ghi_jkl_mno_pqr
|
|||
| Google The UNIX and Linux Forums |