使用sed在一个文件中指定位置插入另外一个文件的内容-r命令的使用

在一个文件的指定位置,比如说匹配到了一个单词的行的下一行开始插入另外一个文件的全部内容,可以使用sed的r命令。

zoer@ubuntu:~/aa$ cat data
here is a 
test naughty loves cc
and so on....

zoer@ubuntu:~/aa$ cat dd
testline1
testline2
zoer@ubuntu:~/aa$ sed '/naughty/r dd' data
here is a 
test naughty loves cc
testline1
testline2
and so on....

上面的命令匹配naughty这个单词并且在该行的下一行开始插入dd文件的内容。


版权声明:本文为imzoer原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。