如何将命令的输出附加到文本文件的末尾?
3 回答

料青山看我应如是
TA贡献1772条经验 获得超8个赞
使用>>而不是>在将输出定向到文件时:
your_command >> file_to_append_to
如果file_to_append_to不存在,将创建它。
例:
$ echo "hello" > file
$ echo "world" >> file
$ cat file
hello
world

泛舟湖上清波郎朗
TA贡献1818条经验 获得超3个赞
到append文件使用 >>
echo "hello world" >> read.txt
cat read.txt
echo "hello siva" >> read.txt
cat read.txt
那么输出应该是
hello world # from 1st echo command
hello world # from 2nd echo command
hello siva
到overwrite文件使用 >
echo "hello tom" > read.txt
cat read.txt
那么输出就是
hello tom
- 3 回答
- 0 关注
- 544 浏览
添加回答
举报
0/150
提交
取消