49

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.

65

Use tee.

user@unknown:~$ sudo command -option | tee log
13

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.

5

You can also use script [ http://linux.die.net/man/1/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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.