linux bash添加文件内容和改写文件内容

linux bash添加文件内容和改写文件内容

 

创建文件

touch test.txt

用vim打开并添加内容:

vim test.txt

this is content

 

添加文件内容

echo "this is another content" >> test.txt

之后内容变成:

this is content

this is another content

 

改写文件内容

echo "this is another content" > test.txt

之后内容变成:

this is another content

 

差别是多了一个>

就变成了添加了内容了。

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:

Leave a Reply

Your email address will not be published. Required fields are marked *