Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that I can log to file by adding

> log.txt 

to the end of a command but how can I log to file AND to console?

share|improve this question
up vote 17 down vote accepted

try using tee?

| tee log.txt

instead of

> log.txt
share|improve this answer

There are various ways by which you can make log. But the first and the foremost thing is what actually you want to put in your log. You can do that in various ways:

  1. Tee command splits the output of a command so that it can be seen on the display and also be saved in a file.

    command | tee log.txt

    The above command will display the output to terminal as well as it will redirect the output to the file log.txt.

  2. The script command makes a typescript(copy) of everything printed on your terminal:

    script -a log.txt
share|improve this answer

Use the tee command:

some_command | tee log.txt
share|improve this answer

Your Answer


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.