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
251 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 50 total points
ID: 20422451
SomeCommand > outputfile.txt && cat outputfile.txt
0
 
LVL 21

Accepted Solution

by:
robocat earned 400 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 50 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How yum repo uses sqlite3 to keep metadata about the repository? 2 45
error log using ftp 7 56
php56-php-mcrypt for rhel7 php56 1 44
CLI command keep running after close 7 36
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

809 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