• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

What does 2>&1 Do?

Can someone fully explain what this does...
 exec > $LogFile.cmd 2>&1
especially 2>&1.
We use Solaris, in bash  
Thanks
0
snydero
Asked:
snydero
  • 2
1 Solution
 
mnewnhamCommented:
1 is the standard output file descriptor
2 is the standard error file descriptor

2>&1 means send standard error to the same place as standard output so

exec > $LogFile.cmd 2>&1 means

redirect any standard output to LogFile.cmd, and send anything from standard error there too.

Another classic example is:

command 1>/dev/null 2>&1
0
 
snyderoAuthor Commented:
Thanks, what does >/dev/null represent?
0
 
mnewnhamCommented:
/dev/null is the black hole down which you may throw anything without the possiblity of using up disk space (or indeed the possibility of retrieval).
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now