You are here

Logging command output


How to display command output (from ls -l in our example) while logging it to a file:

ls -l | tee ls.log

If ls.log already exists, and you don't want to replace it with the new data:

ls -l | tee --append ls.log

To send all messages, including error ones, to the log file:

ls -l 2>&1 | tee ls.log