Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

Example:

ps -aux > log
ps -aux >> log

It seems results is the same.

share|improve this question
add comment

2 Answers 2

up vote 4 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
add comment

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
add comment

Your Answer

 
discard

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.