首页 > 技术文章 > “echo >”和“echo >>”的区别

jetqiu 2020-06-17 18:52 原文

> 输出重定向

>> 输出追加重定向

---------------------------------------------------------------------------------------------------------------------

echo hello A

将字符串hello A输出到屏幕

---------------------------------------------------------------------------------------------------------------------

echo hello A > tmp.txt

将字符串输出重定向,当前目录没有tmp.txt,则创建tmp.txt,并将字符串输出到tmp.txt文件中

tmp.txt内容:hello A

---------------------------------------------------------------------------------------------------------------------

echo hello B > tmp.txt

将字符串输出重定向, 当前目录存在tmp.txt,则将tmp.txt内容替换成输出的字符串

tmp.txt内容:hello B

---------------------------------------------------------------------------------------------------------------------

echo hello C >> tmp.txt

将字符串输出追加重定向,当前目录存在tmp.txt,则将tmp.txt的内容后面追加输出的字符串

tmp.txt内容:hello B hello C

copy from https://www.cnblogs.com/singeryoung/p/9554551.html

推荐阅读