Content #
读取(r)命令允许将一条独立文件中的数据插入数据流。读取命令的格式如下所示:
[address]r filename
filename参数指定了数据文件的绝对路径或相对路径。读取命令中无法使用地址区间,只能指定单个行号或文本模式地址。sed编辑器会将文件内容插入指定地址之后。 $ cat data13.txt This is an added line. This is a second added line. $ $ sed ‘3r data13.txt’ data6.txt This is line number 1. This is line number 2. This is the 3rd line. This is an added line. This is a second added line. This is the 4th line. $ sed编辑器会将数据文件中的所有文本行都插入数据流。在使用文本模式地址时,同样的方法也适用: $ sed ‘/number 2/r data13.txt’ data6.txt This is line number 1. This is line number 2. This is an added line. This is a second added line. This is the 3rd line. This is the 4th line. $ 要在数据流的末尾添加文本,只需使用美元符号地址即可: $ sed ‘$r data13.txt’ data6.txt This is line number 1. This is line number 2. This is the 3rd line. This is the 4th line. This is an added line. This is a second added line. $
From #
Linux命令行与shell脚本编程大全