linux-tutorial/codes/shell/示例脚本/查找替换文本/sed/sed文件操作.sh

25 lines
296 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
#向文件写入
sed '1,2w test1' test1
echo -e "next\n"
#从文件读取
sed '3r ./test' ./test
echo -e "next\n"
#从文件读取,并插入字符流
sed '/lazy/r test' test
#向数据流末尾添加数据
sed '$r test' test
echo -e "next1\n"
sed '/lazy/ {
r test
d
}' test