Server Fault is a question and answer site for system and network administrators. 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 want to save a program's output (stdout) to a file but still be able to see the output on the screen in realtime.

I need a solutions for both Linux and Windows.

share|improve this question
up vote 4 down vote accepted

In Linux, you can use the tee utility.

In Windows, PowerShell contains a tee cmdlet. For cmd, you will need to download and install a separate utility.

share|improve this answer

On Linux and similar systems:

program | tee filename

The tee program sends anything that comes into its standard input to its standard output (like cat) and also writes it to the specified file.

Another way to get the same effect would be

program >filename 2>/dev/null &
tail -f filename

This runs the program in the background, redirecting its standard output to the file, then tail -f lets you follow data being written to the file in real time (or nearly so, maybe a fraction of a second delay). The 2>/dev/null makes the standard error stream disappear so that it doesn't interfere with the output of tail -f.

share|improve this answer

Linux: command | tee logfile

Windows: Install cygwin, then run: command | tee logfile

share|improve this answer

For Windows you can do this:

dir > directory.txt & type directory.txt

where you'd replace dir by your application.

If the output scrolls too fast use:

dir > c:\directory.txt & type c:\directory.txt | more

However, I don't think this would display the contents of the file in real time. You'd have to wait until the process had finished.

share|improve this answer

In Windows, you can use tee if you download the GnuWin32 version of it. It's the same as the linux app and comes from the coreutils package.

One word of caution, though: tee has its own return code, so you won't be able to notice errors from the process piped to it (unless you're in linux, then there are ways around it).

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.