LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-22-2007, 09:32 AM   #1
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Manjaro
Posts: 963

Rep: Reputation: 36
redirecting stderr to a pipe


i want to call a command in a shell script then redirect stderr to a pipe to tee with stdout still going to the screen.

i tried

Code:
command arguments 2| tee errlog.txt
but it interpritaded 2 as an aditional argument

what woudl i use to get the effect i want

Last edited by dasy2k1; 03-22-2007 at 09:39 AM.
 
Old 03-22-2007, 09:56 AM   #2
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
i believe you should replace "2|" with "2>"
 
Old 03-22-2007, 11:05 AM   #3
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Manjaro
Posts: 963

Original Poster
Rep: Reputation: 36
ah got it... replace the | withj > and surround the tee command in backticks
 
Old 03-22-2007, 11:28 AM   #4
henrysukumar
Member
 
Registered: Feb 2007
Location: Bangalore
Distribution: Fedora
Posts: 33

Rep: Reputation: 15
command 2>&1 | tee sample.log

i think this will help u. For eg. ls -w 2>&1 | tee sample.log

The above command 'ls' does not have '-w' option, will throw error on screen & as well as stores in sample.log
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
separte pipe for stderr and stout in a bash script ask4info Programming 7 09-07-2012 01:39 AM
Redirecting stdout, stderr to pty0? Rostfrei Linux - General 4 03-20-2007 03:15 AM
Redirecting error messages to stderr and file in Bash lowpro2k3 Programming 1 04-14-2005 06:47 PM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 07:55 AM
redirecting stderr nodger Programming 2 03-11-2004 10:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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