Linux - I am redirecting a command to a file, but I also want to see the output on the screen


I'm running command like this, to redirect output to a file

SomeCommand > outputfile.txt

I would also like to see the output on the screen.

How can I achieve this?

Thank you for your time
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

robocatConnect With a Mentor Commented:

From another terminal, you can start a

tail -f outputfile.txt

Another interesting way to do this is using the "tee" command

SomeCommand | tee outputfile.txt

The tee command will send the output to the screen and to the file

killbradConnect With a Mentor Commented:
SomeCommand > outputfile.txt && cat outputfile.txt
sardiskanConnect With a Mentor Commented:
There are some fancy scripting techniques you can use to do that, but if you are looking for a command line answer, and you don't need to see the output AS it happens, I'd do this:
# somecmd > outputfile.txt && cat outputfile.txt

Open in new window

Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

oxygen_728Author Commented:
thanks, the tee command looks great
you can use the  "tee" command  

like this:

somecommand | tee outputfile.txt

Thanks for that info about tee command.. wasn't aware of that.. good show!  :-)
All Courses

From novice to tech pro — start learning today.