What's the difference between using > and >> in shell? What's the difference between using > and >> in shell? shell shell

What's the difference between using > and >> in shell?


>> is for appending whereas > is for writing (replacing).


If the file exists, >> will append to the end of the file, > will overwrite it.

Both will create it otherwise.


There is a difference if the file you're redirecting to already exists:

> truncates (i.e. replaces) an existing file.

>> appends to the existing file.