Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-24-2005, 01:50 AM   #1
Registered: Aug 2005
Distribution: Debian 'lenny'
Posts: 208

Rep: Reputation: 30
Possible to pipe output and error to a file while displaying them on monitor?

Would it be possible to display the results of 'cat testfile' on the monitor while piping the standard output and error to a file? I tried 'cat testfile &> capturedfile', but the content of 'testfile' is not displayed on the monitor (the content is however piped successfully into the capturedfile).

Also, does the tee command capture error output in the file (capturedfile) too? Eg.

'cat testfile |tee capturedfile'

Thanks !
Old 11-24-2005, 02:01 AM   #2
Registered: Aug 2005
Location: Ukraine
Distribution: Ubuntu 9.04
Posts: 99
Blog Entries: 3

Rep: Reputation: 19
To capture the stderr, you need to use the second descriptor (first iss the stdout), like
cat myfile.txt 2>&1 | tee myfile
which makes the stderr go to stdout and then through the pipe to 'tee', which will log it and print.
Old 03-29-2006, 05:04 AM   #3
Registered: Apr 2003
Location: Vancouver
Distribution: Debian
Posts: 37

Rep: Reputation: 15
Cool! I was going to post a message about that, but you'd answered it. Thanks.


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
pipe output to append to a text file davee Linux - Newbie 5 03-22-2016 07:44 PM
how to pipe output from make BBB Programming 2 05-20-2005 06:14 AM
pipe xine output to file sohmc Linux - Software 0 01-01-2005 10:03 PM
Pipe telnet session output to text file joshlamerritt Linux - Software 3 02-10-2004 08:42 PM
Output truncated when using pipe tells Linux - General 1 12-16-2003 08:06 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:45 PM.

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