Bash – sed + how to delete the second character “.” from the line

bashlinuxsed

how to delete the second character "." from the line

what I have is this ( but its remove the first "." from output

uname -r | sed s'/\./ /'

2 6.18-164.2.1.el5PAE

while I need the following output

2.6 18-164.2.1.el5PAE

Best Answer

Simply add N to the end of the command for it to match the Nth match, like this:

uname -r | sed 's/\./ /2'

What do you need it for though?


From the info page on sed:

The `s' command can be followed by zero or more of the following FLAGS:

g

Apply the replacement to _all_ matches to the REGEXP, not just the first.

NUMBER

Only replace the NUMBERth match of the REGEXP.
Related Question