linux-tutorial/codes/shell/查找替换文本/sed/sed文件操作.sh
2019-10-29 18:22:19 +08:00

25 lines
304 B
Bash

#!/usr/bin/env 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