Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does 2>&1 perform?

Status
Not open for further replies.

octar

Technical User
Oct 21, 2002
28
AU
I have seen it in many scripts but don't understand what it performs. Thanks in advance
 
Hi,

Basically it sends "standard error" to "standard output".

If you do not redirect the errors - in the script log file you may end up missing the system response to error conditions raised by the script.

This is done to capture both the command output and error. "Long live king Moshiach !"
h
 
Say you type `cat /etc/sendmail.cf > /tmp/junk 2>&1`, this will cat /etc/sendmail.cf and redirects standard out (1) to the file /tmp/junk and if there are any errors it redirects standard error (2) to the file.
 
I like to stick a 2>/dev/null on the end of a find command so that I don't have to see all the directories I don't have access to.

It is possible to define your own file descriptors but that is a bit advanced for what I usually do. IBM Certified -- AIX 4.3 Obfuscation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top