Super User is a question and answer site for computer enthusiasts and power users. 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 am using:

user@unknown:~$ sudo command -option > log

to save the results of "command" to the file "log", but I'd like to also get the result on the terminal, is this possible?

I am using ubuntu 10.04 lts.

share|improve this question
Possible duplicate of Echoing output to file while seeing it in console in the same time – 8bittree Nov 24 '15 at 18:09
@8bittree This post is 3 years older and has more views and votes than the other question. The other question should be closed as a duplicate instead. – Excellll Nov 30 '15 at 15:28
@Excellll Age is irrelevant. I flagged this as the duplicate because I believe that the other has a superior answer. – 8bittree Nov 30 '15 at 18:05
up vote 48 down vote accepted

Use tee.

user@unknown:~$ sudo command -option | tee log
share|improve this answer

The command you're looking for is 'tee' which makes a data connection similar to a pipe-tee. it sends data two ways. So

sudo command -option | tee log

would tee the command output to both the file 'log' and to stdout, in this case, your terminal.

share|improve this answer

You can also use script [ ] to capture everything that occurs in your terminal session.

Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .