1、测试数据如下:
[root@centos79 test]# ls a.txt b.txt [root@centos79 test]# cat a.txt 3 4 5 d g 3 s g 8 k s g 2 5 d s c w a r t e 4 s [root@centos79 test]# cat b.txt Beijing 2003 Beijing 2004 Beijing 2005 Beijing 2006 Beijing 2007 Beijing 2008
2、在a.txt文件的第2行后插入b.txt文件
[root@centos79 test]# cat a.txt 3 4 5 d g 3 s g 8 k s g 2 5 d s c w a r t e 4 s [root@centos79 test]# cat b.txt Beijing 2003 Beijing 2004 Beijing 2005 Beijing 2006 Beijing 2007 Beijing 2008 [root@centos79 test]# sed '2r b.txt' a.txt 3 4 5 d g 3 Beijing 2003 Beijing 2004 Beijing 2005 Beijing 2006 Beijing 2007 Beijing 2008 s g 8 k s g 2 5 d s c w a r t e 4 s
3、在a.txt文件中匹配d的行后插入b.txt文件
[root@centos79 test]# cat a.txt 3 4 5 d g 3 s g 8 k s g 2 5 d s c w a r t e 4 s [root@centos79 test]# cat b.txt Beijing 2003 Beijing 2004 Beijing 2005 Beijing 2006 Beijing 2007 Beijing 2008 [root@centos79 test]# sed '/d/r b.txt' a.txt 3 4 5 d g 3 Beijing 2003 Beijing 2004 Beijing 2005 Beijing 2006 Beijing 2007 Beijing 2008 s g 8 k s g 2 5 d Beijing 2003 Beijing 2004 Beijing 2005 Beijing 2006 Beijing 2007 Beijing 2008 s c w a r t e 4 s
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。