LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-20-2007, 08:02 AM   #1
pobbz
LQ Newbie
 
Registered: Jul 2006
Distribution: Fedora, Debian, DSL
Posts: 24

Rep: Reputation: 15
demultiplexing bash stdout stream


Hello.

I have a simple BASH question: How can I demultiplex output of a command to two separate streams?

What I want to do is to direct the output of a command to a file AND to stdout (I want to both see the output of the command AND store it to a file). It doesn't seem to work, if I, for instance, say
Code:
[user@box]$ ls -la  >output.dat 1>&1
Is there a simple way to accomplish this by stream redirection in BASH?

Thanks.
 
Old 06-20-2007, 08:09 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Yeppers - use the "tee" command.

ls -la |tee output.dat
Would send to stdout AND to the file output.dat.

ls -la 2>&1 |tee output.dat
Would send both stderr and stdout to stdout AND to the file output.dat.


ls -la | tee -a output.dat
Would send to stdout AND append to the file output.dat.

Type "man tee" for more information on this command.

P.S. Questions with 5 syllable words in the title are seldom viewed as "simple".
 
Old 06-20-2007, 11:35 PM   #3
pobbz
LQ Newbie
 
Registered: Jul 2006
Distribution: Fedora, Debian, DSL
Posts: 24

Original Poster
Rep: Reputation: 15
Thanks, dude! Just what I was lookin for.
 
Old 06-21-2007, 09:14 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
No problem.

Thanks for the feedback - many newbies never post follow ups so you always wonder if they abducted by aliens after the initial post.
 
  


Reply



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
Howto transcode & relay a MPEG stream to a WMV stream?? crazyivan Linux - Software 0 06-15-2007 03:18 AM
Bash problem: detecting end of stream tvynr Linux - Software 2 11-08-2006 10:12 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 02:36 AM
bash + manipulate stdout to console dave bean Programming 1 02-21-2005 06:44 AM
how to redirect stdout [binary stream] to multiple processes vtaminh Linux - General 2 08-19-2004 01:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:44 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration