mirror of
https://github.com/dunwu/linux-tutorial.git
synced 2024-04-15 19:55:24 +08:00
25 lines
304 B
Bash
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
|