DelphiFAQ Home Search:

How to redirect stderr in Unix

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Question:

I forgot how to redirect stderr in Unix.

Answer:

> will redirect stdout. Use the &> operator to redirect stderr:

rm backup.zip &>junk

It works in the Windows shell too.


Comments:

2006-12-01, 17:26:26
anonymous from United States  
its >&
2008-03-12, 15:16:36
anonymous from United States  
Actually its neither of the above.
1 = std out file descriptor
2 = std err file descriptor

so the following redirects stderr to a file named 'junk'

rm backup.zip 2>junk

and the following redirects both stdout and stderr into a file named junk

rm backup.zip 1>junk 2>&1

the >& says to use the same file used by '1'

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
Leave your comment here:
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.