我怎样才能用_N_th命令来替代sed(例如,第三次)在一个文件中的再加工(或模式)的发生?我指的是在该文件中发生的_N_th,而不是在一条线路或第一条发生的in the _N_th匹配线中发生的_N_th,而不是在一条线路或第一条发生的in the _N_th匹配线中发生的_N_th。
示例:
只将文件中is的第三次出现改为us。
我的输入文件包含:
hai this is linux.
hai this is unix.
hai this is mac.
hai this is unchanged.预期产出如下:
hai this is linux.
hai thus is unix.
hai this is mac.
hai this is unchanged.请注意,在第二行中,“this”已被“by”替换为“by”。
发布于 2022-06-23 07:27:57
使用sed with -z选项定义要替换的事件。
sed -i -z "s/is/us/3" pom.xml your.filehttps://unix.stackexchange.com/questions/181771
复制相似问题