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: 18 June 2018, 11:49 AM EDT
Location: Simplicity
Posts: 4,118
Thanks: 357
Thanked 1,400 Times in 1,258 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'