Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-12-06
6
Medium Priority
?
274 Views
Last Modified: 2013-12-16
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
0
Comment
Question by:oxygen_728
6 Comments
 
LVL 7

Assisted Solution

by:killbrad
killbrad earned 200 total points
ID: 20422451
SomeCommand > outputfile.txt && cat outputfile.txt
0
 
LVL 22

Accepted Solution

by:
robocat earned 1600 total points
ID: 20422459

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
 
LVL 5

Assisted Solution

by:sardiskan
sardiskan earned 200 total points
ID: 20422473
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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Closing Comment

by:oxygen_728
ID: 31413232
thanks, the tee command looks great
0
 
LVL 7

Expert Comment

by:broeckske
ID: 20422564
you can use the  "tee" command  

like this:

somecommand | tee outputfile.txt

0
 
LVL 7

Expert Comment

by:killbrad
ID: 20422639
Thanks for that info about tee command.. wasn't aware of that.. good show!  :-)
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month5 days, 20 hours left to enroll

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question