Wednesday, May 1, 2024
91
rated 0 times [  91] [ 0]  / answers: 1 / hits: 164476  / 2 Years ago, wed, january 12, 2022, 5:59:36

Could someone explain to me the difference between > and >> when using shell commands?



Example:



ps -aux > log
ps -aux >> log


It seems the result is the same either way.


More From » command-line

 Answers
2

> is used to overwrite (“clobber”) 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.


[#28227] Friday, January 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uffno

Total Points: 283
Total Questions: 93
Total Answers: 111

Location: Saint Vincent and the Grenadines
Member since Thu, Oct 15, 2020
4 Years ago
uffno questions
Thu, Sep 2, 21, 18:08, 3 Years ago
Sun, Apr 2, 23, 15:15, 1 Year ago
Sat, Jan 8, 22, 16:37, 2 Years ago
;