Sed在匹配行前后加入一行

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

1 #行前加
2 sed -i '/allow chengyongxu.com/iallow chengyongxu.cn' the.conf.file
3 #行前后
4 sed -i '/allow chengyongxu.com/aallow chengyongxu.cn' the.conf.file