LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-14-2005, 12:45 PM   #1
Quantum0726
Member
 
Registered: Dec 2003
Location: Milwaukee, WI
Distribution: Gentoo
Posts: 39

Rep: Reputation: 15
Redirecting to file and stdout


Hi, I would like to find a way to be able to redirect output to a file, but still have it display on the screen, i.e. just copy it to a file as the command is running. Now I have been using the standard &> operator to redirect it all to a file, using the command in a screen. Then I run tail -f on the file and I can see the output as it's written. Is there a way to do this using redirection operators? Or just a better way than I am doing it?

Thanks much!
 
Old 11-14-2005, 12:50 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Code:
man tee
 
Old 11-14-2005, 12:52 PM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
You're looking for the tee command. As in:
Code:
$ ls -l | tee directory_listing.txt
Tee displays what it receives as standard input to the screen and also writes it verbatim to the specified file.
 
Old 11-14-2005, 08:35 PM   #4
Quantum0726
Member
 
Registered: Dec 2003
Location: Milwaukee, WI
Distribution: Gentoo
Posts: 39

Original Poster
Rep: Reputation: 15
tee works perfectly. Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why when redirecting output to a file any file extension seems to be fine? dr_zayus69 Linux - General 1 05-21-2005 04:09 AM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 07:55 AM
Redirecting stdout to tar hari_s_82 Linux - Newbie 6 10-08-2004 01:49 AM
redirecting stdin and stdout with pipes: convincing apps they're for a terminal? prell Programming 1 09-02-2004 06:38 AM
Redirecting stdout from tar to a text file. heatlill Programming 2 01-22-2002 10:27 AM


All times are GMT -5. The time now is 07:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration