shell/初识sed和gawk/sed文件操作.sh

25 lines
296 B
Bash
Raw Normal View History

2016-05-18 15:54:22 +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