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
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

752 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