Sunday, May 29, 2016

command line - How do I save terminal output to a file?




How do I save the output of a command to a file?



Is there a way without using any software? I would like to know how.



Yes it is possible, just redirect the output to a file:



SomeCommand > SomeFile.txt  


Or if you want to append data:




SomeCommand >> SomeFile.txt


If you want stderr as well use this:



SomeCommand &> SomeFile.txt  


or this to append:




SomeCommand &>> SomeFile.txt  


if you want to have both stderr and output displayed on the console and in a file use this:



SomeCommand 2>&1 | tee SomeFile.txt


(If you want the output only, drop the 2 above)



No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...