The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to redirect stderr from top with csh umen Shell Programming and Scripting 2 02-22-2007 10:19 PM
csh stderr redirection jolok Shell Programming and Scripting 0 04-15-2005 07:03 AM
'tee' STDERR output (ksh) gsatch Shell Programming and Scripting 5 08-21-2002 09:19 AM
stderr redirection in csh script thehoghunter Shell Programming and Scripting 0 01-28-2002 07:15 AM
stderr dell9 High Level Programming 1 11-21-2001 03:49 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-12-2002
Registered User
 

Join Date: Oct 2002
Location: London
Posts: 13
stderr redirection

Does anyone know away of redirecting the stderr for a bourne or korn shell script to a file.
Forum Sponsor
  #2  
Old 12-12-2002
Ralf's Avatar
Registered User
 

Join Date: Oct 2002
Posts: 34
I though it was the same for all shells?

This shold produce a file 'junk.txt' with an error from stderr

Code:
$ RunFail > junk.txt 2>$1
  #3  
Old 12-12-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Actually it's:
$ RunFail > junk.txt 2>&1

That is you need an ampersand, not a dollar sign. And that syntax will not work with csh or csh clones.
  #4  
Old 12-12-2002
Registered User
 

Join Date: Oct 2002
Location: London
Posts: 13
Thanks Perderabo.

I I rewrite it as:
RunFail >> junk.txt 2>>&1

will it append to the file?
  #5  
Old 12-12-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
There is no such thing as 2>>&1

>> junk.txt
will open the file in append mode and attach it to fd 1

2>&1
will duplicate fd 1 and attach it to fd 2. You use this form for everything. It does not matter how fd 1 came to exist.
  #6  
Old 12-12-2002
Ralf's Avatar
Registered User
 

Join Date: Oct 2002
Posts: 34
Opps to my typo

thanks Perderabo
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0