Unix/Linux Go Back    

How to replace special characters?

UNIX for Advanced & Expert Users

Kindly Note - This is a Single User Post by Forum Member MadeInGermany Regarding:
How to replace special characters?.
Please Follow The Primary Link Above to View the Full Discussion.

Old Unix and Linux 04-22-2017   -   Original Discussion by Ravi.K
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Join Date: May 2012
Last Activity: 20 March 2018, 11:40 PM EDT
Location: Simplicity
Posts: 4,008
Thanks: 343
Thanked 1,346 Times in 1,214 Posts
Post#4 requires the match at the beginning of the string.
Post#2 does only one substitution and also does it for A.B.
The following requires a digit after the dot, and because it is part of the match must mark it in \( \) and put it back via a back-reference. Also it does the substitution globally.

echo '|*|.5|*|0.2|*|A.B|*|' | sed 's/|\(\.[0-9]\)/|0\1/g'