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:

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'

 

 

NEW: Optional: Register   Login
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, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

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.

photo Add a picture: