sed + 如何删除第二个字符“.” 从线

mai*_*ash 6 linux bash sed

如何删除第二个字符“.” 从线

我所拥有的是这个(但它从输出中删除了第一个“。”

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

2 6.18-164.2.1.el5PAE
Run Code Online (Sandbox Code Playgroud)

虽然我需要以下输出

2.6 18-164.2.1.el5PAE
Run Code Online (Sandbox Code Playgroud)

rem*_*mmy 14

只需在命令末尾添加 N 即可匹配第 N 个匹配项,如下所示:

uname -r | sed 's/\./ /2'
Run Code Online (Sandbox Code Playgroud)

你需要它做什么?


info页面上sed

`s' 命令后面可以跟零个或多个以下标志:

G

Apply the replacement to _all_ matches to the REGEXP, not just the first.
Run Code Online (Sandbox Code Playgroud)

数字

Only replace the NUMBERth match of the REGEXP.
Run Code Online (Sandbox Code Playgroud)