Posted on 收藏

 

a 追加内容 sed ‘/匹配词/a\要加入的内容’ example.file(将内容追加到匹配的目标行的下一行位置)
i 插入内容 sed ‘/匹配词/i\要加入的内容’ example.file 将内容插入到匹配的行目标的上一行位置)
示例:
#我要把文件的包含“linux.com”这个关键词的行前或行后加入一行,内容为“allow linux.cn”

1 #行前加
2 sed -i '/allow linux.com/i\allow       linux.cn'    the.conf.file
3 #行前后
4 sed -i '/allow linux.com/a\allow     linux.cn' the.conf.file

 

a 追加内容 sed ‘/匹配词/a\要加入的内容’ example.file(将内容追加到匹配的目标行的下一行位置)
i 插入内容 sed ‘/匹配词/i\要加入的内容’ example.file 将内容插入到匹配的行目标的上一行位置)
示例:
#我要把文件的包含“linux.com”这个关键词的行前或行后加入一行,内容为“allow linux.cn”

1 #行前加
2 sed -i '/allow linux.com/i\allow       linux.cn'    the.conf.file
3 #行前后
4 sed -i '/allow linux.com/a\allow     linux.cn' the.conf.file

相关文章:

  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-10-21
相关资源
相似解决方案