技术小黑屋

BashBites:How to Append Outputs to a File

Is there any way to append output(debugging information) to a existings file? As we all know in bash the command ‘>’ will write ouputs to a file.However this command will also erase the existing data it the file.
Of course bash provides a command that appends outputs to a file.It resembles ‘>’.It’s ‘>>’
The following is a piece of example code.

Let’s look at >
1
2
3
4
5
6
7
8
[androidyue@androidyue tmp]$ touch a.txt
[androidyue@androidyue tmp]$ cat a.txt
[androidyue@androidyue tmp]$ echo "ABC" > a.txt
[androidyue@androidyue tmp]$ cat a.txt
ABC
[androidyue@androidyue tmp]$ echo "DEF" > a.txt
[androidyue@androidyue tmp]$ cat a.txt
DEF
Well,Let’s look at the exiciting command >>
1
2
3
4
[androidyue@androidyue tmp]$ echo "GHI" >> a.txt
[androidyue@androidyue tmp]$ cat a.txt
DEF
GHI




快来解锁最新版 Typora,新用户券后仅需 84 元!
如何便宜的购买 office 365 ?
新版赤友 NTFS 助手来袭,正版超低价