我在某处看到我们可以在shell中使用>>。 在shell中使用>和>>有什么区别?在shell中使用>和>>有什么区别?
3
A
回答
10
>>
用于追加,而>
用于写入(替换)。
4
是有区别的,如果你重定向到文件已经存在:
>
截断(即替换)现有文件。
>>
附加到现有文件。
5
1
'>>'会让你追加数据到一个文件,其中'>'将覆盖它。例如:
# cat test
test file
# echo test > test
# cat test
test
# echo file >> test
# cat test
test
file
0
当您使用>,如:
$ echo "this is a test" > output.txt
>运算符将完全如果存在覆盖该文件output.txt中的任意内容。如果该文件不存在,则会创建内容为“这是一个测试”。
这个用法:
$ echo "this is a test" >> output.txt
将添加链接 “这是一个测试” 在output.txt的任何内容(称为 '附加')。如果文件不存在,它将被创建,文本将被添加。
0
在这里添加更多的知识。
我们也可以使用tee
命令来执行相同的:
cat newfile | tee filename - rewrites/replaces the file with new content in filename
cat newfile | tee -a filename - appends to the existing content of the file in filename file
+1
双用无用猫。 – Jens 2012-05-30 20:00:30
相关问题
- 1. 在Purescript; - >和=>有什么区别?
- 2. Java中> =和=>有什么区别?
- 3. > =和=>有什么区别?
- 4. <%# %>和<%= %>有什么区别?
- 5. 运算符>>>在Java和JavaScript中有什么区别?
- 6. 运算符>>和运算符>>>在java中有什么区别?
- 7. Postgres SQL中` - >>`和` - >`有什么区别?
- 8. 有什么区别使用<?php ... ?>和<? ... ?>
- 9. 在php中=>和 - >有什么区别?
- 10. PHP中的 - >和::有什么区别?
- 11. Java操作符>>和>>>之间有什么区别?
- 12. 区别<p>是什么Javascript和ASP.net有什么区别?</p>
- 13. Java Facelets中的<h:head>和<head>有什么区别?
- 14. Rails erb中的<% code %>和<%= code %>有什么区别?
- 15. RSS中的<pubDate>和<lastBuildDate>有什么区别?
- 16. ASP.NET中的<%#Bind(“”)%>和<%#Eval(“”)%>有什么区别?
- 17. asp.net中<%= %>语法和<%# %>有什么区别?
- 18. jsp中的<% ... %>和<%! ... %>有什么区别
- 19. <foo></foo>和JAXB中的null有什么区别?
- 20. 系统verilog断言中的 - >和=>有什么区别?
- 21. <span></span>标签和在.css中使用span有什么区别?
- 22. $ request-> file-> store($ path)和$ request-> file-> move($ path,$ filename)有什么区别?
- 23. puppet,'='和'=>'有什么区别
- 24. 变量的=和=>有什么区别?
- 25. 有什么区别:to和=> in rails
- 26. Perl中“>>”和“>”的区别
- 27. `$ this-> name`和`$ this - > $ name`之间有什么区别?
- 28. () - >单位和(单位) - >单位类型有什么区别?
- 29. 列表<string>和IEnumerable <String>有什么区别?
- 30. <input type =“button”/>和<button>之间有什么区别?
会是什么的一个例子>>? – goe 2009-12-16 20:50:32
是的,当你使用>时要小心,因为如果文件已经存在,它将完全覆盖文件,而如果没有文件,或者它会创建一个新文件,或者开始追加到现有文件的末尾。 – 2009-12-16 20:51:11
@goe:你会使用'>>'继续在文件末尾添加一行。例如,一个日志文件。 – 2009-12-16 20:52:05