Reputation: 2642
I'd like to be able to replace 1
with 1.
in a block of text I have with varying numbers.
So, how can I find out the matched digit to use in the replace?
Here's an example :
echo "1 MORE TEXT HERE" | sed 's/[0-9]/[0-9]\./g'
I'd like the [0-9]
in the 2nd part of sed
to give me the match.
Upvotes: 3
Views: 166
Reputation: 41456
A solution using gnu awk
echo "1 MORE TEXT HERE" | awk '{print gensub(/[[:digit:]]*/,"&.","")}'
1. MORE TEXT HERE
Upvotes: 0
Reputation: 32066
echo "1 MORE TEXT HERE" | sed 's/[0-9]/&\./g'
&
is the full match
Upvotes: 5