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

Hi.

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
oxygen_728Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
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

0
 
killbradConnect With a Mentor Commented:
SomeCommand > outputfile.txt && cat outputfile.txt
0
 
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

0
Never miss a deadline with monday.com

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
0
 
broeckskeCommented:
you can use the  "tee" command  

like this:

somecommand | tee outputfile.txt

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

From novice to tech pro — start learning today.