HI Folks,
I'm looking for a solution for this issue.
I want to find the Pattern 0[0-9]/ and replace it with [0-9]/. I'm just removing the leading zero. I can find the Pattern but it always puts literal value as a replacement.
What am I missing??
sed -e s/0[0-9]\//[0-9]\//g File1 > File2
sed doesn't work that way. putting [0-9] in the output pattern will not cause it to substitute any of the input.
To do that, you want a backreference.
sed 's#0\([0-9]\)/#\1/#'
1 Like
You need the "\(...\)" device for this. This way you can replicate parts of the matched regexp in the substitution:
sed 's/0\([0-9]\)/\1/'
will replace any "0" followed by a digit with this digit and omit the leading "0".
I hope this helps.
bakunin
1 Like