Linux sed命令 以行为单位编辑文本,或替换文本中的文字

sed -e 4a\newLine testfile 

首先查看testfile中的内容如下:

$ cat testfile #查看testfile 中的内容  
HELLO LINUX!  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
Linux test 

使用sed命令后,输出结果如下:

$ sed -e 4a\newline testfile #使用sed 在第四行后添加新字符串  
HELLO LINUX! #testfile文件原有的内容  
Linux is a free unix-type opterating system.  
This is a linux testfile!  
Linux test  
newline   

posted on 2019-01-14 20:06  梓沂  阅读(363)  评论(0编辑  收藏  举报