Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anybody could explain to me the difference using > and >> when using shell command ?


ps -aux > log
ps -aux >> log

It seems results is the same.

share|improve this question
For additional info on some of the bash operators , refer also to What's the difference between <<, <<< and < < in bash? – Serg Oct 6 '15 at 3:20
up vote 11 down vote accepted

> is used to write to a file and >> is used to append to a file.

Thus, when you use ps aux > file, the output of ps aux will be written to file and if a file named file was already present, its contents will be overwritten.

And if you use ps aux >> file, the output of ps aux will be written to file and if the file named file was already present, the file will now contain its previous contents and also the contents of ps aux, written after its older contents of file.

share|improve this answer

if you write in terminal

ps aux > log

It will put the output of ps aux to log named file.

then if you put

ps aux >> log

then the next output will be appended below the first. if you put only one > it will overwrite the previous file.

share|improve this answer

Yes, >> appends, > always overwrites/destroys the previous content.

ps -aux > log

is the same as

rm log 2>/dev/null
ps -aux >> log

On Wintel it is the same for .bat, .cmd and .ps1 scripts too; common heritage, common sense.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.