Can I Save The Output From Terminal Into A File?

This is a quick one, and easy to answer.

Yes it is possible, just redirect the output (AKA stdout) 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)


If you have any comments, feel free to post them below or find us on Twitter and Facebook!

Until next time!

February 12 2021

Add or review comments

Please leave your comment

Existing comments

Comments 0