Difference between ‘>’ & ‘>>’

I always wonder what is the difference between ‘>’ sign and ‘>>’ sign in Linux

when want to redirect the output of a command such as ‘ls’ to a file.

I thought both do the same task without any difference and

finally while I was making my own playlist for playing songs in my favorite player(mpg123), I found the difference.

Basically the difference is really simple, ‘>’ overwrites the file but ‘>>’ appends output to the end of file.

For instance,

$ ls > t1.txt

overwrite ‘t1.txt’ and erase its previous data. However,

$ ls >> t1.txt

appends the output to the end of ‘t1.txt’ file.

send your idea to kasra.madadipouya@geeksweb.tk

Leave a Reply

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