简体   繁体   English

“>”和“ >>”有什么区别?

[英]What's the difference between '>' and '>>'?

What's the difference between 之间有什么区别

cat int.txt > out.txt

and

cat int.txt >> out.txt

Does the >> do anything differently from > ? >>>有什么不同吗?

The > will overwrite out.txt if it already exists. >将覆盖out.txt如果已存在)。 The >> will simply append to out.txt . >>将简单地附加到out.txt

> overwrites to the file. >覆盖文件。 >> appends to the file. >>追加到文件。

>> will append to out.txt if it exists >>将附加到out.txt(如果存在)

> will overwrite out.txt if it exists >将覆盖out.txt(如果存在)

> is to re-direct standard output to the file and overwrite it if the file exists. >将标准输出重定向到文件,并在文件存在时覆盖它。

>> is to append standard output to the file if it exists >>用于将标准输出附加到文件(如果存在)

Some more options: 其他一些选择:

http://www.mathinfo.u-picardie.fr/asch/f/MeCS/courseware/users/help/general/unix/redirection.html http://www.mathinfo.u-picardie.fr/asch/f/MeCS/courseware/users/help/general/unix/redirection.html

cat int.txt > out.txt

This has written the contents of int.txt to out.txt and overwritten anything that was in that file (out.txt) if it already existed. 这已将int.txt的内容写入out.txt,并覆盖了该文件(out.txt)中已存在的所有内容。

cat int.txt >> out.txt

This has appended int.txt to the end of out.txt if it existed or simply created it if it didn't, and copied int.txt into it. 如果存在,则将int.txt附加到out.txt的末尾;如果不存在,则将其简单创建,然后将int.txt复制到其中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM