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
249 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SIP Trunk provider 20 95
LDAP find expired users 8 46
Auto channel for WiFi (Access Point) 3 51
bash script question (chmod) 10 41
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now