流编辑器,一般对文件进行增删改查

格式

sed** [-options] ‘script’ files
sed:命令
[-options]:参数
‘script’编辑命令和内容
files:编辑文件**

常见参数

-n:取消默认输出,只显示经过sed处理或匹配的行(常用)
-e:直接在命令模式上进行sed的动作编辑,接要执行的一个或者多个命令
-i:直接修改读取的文件内容,不输出。

‘script’

格式

[address]** **command
[address] :要处理哪一行
command:要怎样处理

常见[address]

image.png

常见command

image.png

常见用法

在后面插入一行

image.png

在前面插入一行

image.png

删除1到3行

image.png

多命令插入行

image.png

替换指定行的内容

image.png

替换指定内容

image.png
image.png