linux 中sed r选项的作用
r选项的作用表示在文件中匹配B, 然后读入a.txt的内容, 添加到B的后面
001、
(base) [root@PC1 test2]# ls a.txt b.txt (base) [root@PC1 test2]# cat a.txt 1 2 3 4 5 (base) [root@PC1 test2]# cat b.txt big nowcoder Betty basic test (base) [root@PC1 test2]# sed '/B/r a.txt' b.txt big nowcoder Betty 1 2 3 4 5 basic test
002、
(base) [root@PC1 test2]# ls a.txt b.txt (base) [root@PC1 test2]# cat a.txt 1 2 3 4 5 (base) [root@PC1 test2]# cat b.txt big nowcoder Betty basic test (base) [root@PC1 test2]# sed '2r a.txt' b.txt ## 可以直接指定行数 big nowcoder 1 2 3 4 5 Betty basic test