相关疑难解决方法(0)

使用sed删除不区分大小写的匹配行

如何匹配不区分大小写的正则表达式并同时删除它

我读到这个以获得不区分大小写的匹配,使用标志"i"

sed -e "/pattern/replace/i" filepath
Run Code Online (Sandbox Code Playgroud)

并删除使用d

sed -e "/pattern/d" filepath
Run Code Online (Sandbox Code Playgroud)

我还读到我可以组合多个标志,如2iw

我想知道sed是否可以将i和d结合起来我尝试过以下但是它没有用

sed -e "/pattern/replace/id" filepath > newfilepath
Run Code Online (Sandbox Code Playgroud)

sed case-insensitive

32
推荐指数
1
解决办法
2万
查看次数

使用sed命令在File中的两个模式之间添加文本

我想在两个模式之间添加一些大代码:

FILE1.TXT

This is text to be inserted into the File.
Run Code Online (Sandbox Code Playgroud)

infile.txt

Some Text here
First
Second
Some Text here
Run Code Online (Sandbox Code Playgroud)

我想在FirstSecond之间添加File1.txt内容:

期望的输出:

Some Text here
First
This is text to be inserted into the File.
Second
Some Text here
Run Code Online (Sandbox Code Playgroud)

我可以使用sed命令使用两种模式进行搜索,但我不知道如何在它们之间添加内容.

sed '/First/,/Second/!d' infile 
Run Code Online (Sandbox Code Playgroud)

unix linux sed

6
推荐指数
1
解决办法
9959
查看次数

标签 统计

sed ×2

case-insensitive ×1

linux ×1

unix ×1