Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a way this question is a extension of another question.

In bash you can do pretty neat stuff with file descriptors. Like

{ command > /dev/null } 2>&1 | grep filter;

to grep on stderr only.

My Question[s]:

  • How many levels of descriptors are there. ( How high can the "numbers" go) ?
  • Appart from 1 and 2 ( which are stdout and stderr ), what is the meaning and general use of those other "numbers"?
  • Is the order in which they are specified important?
    e.g. command 1>&2 3>&1 2>&3 versus command 2>&3 3>&1 1>&2
share|improve this question
You probably knew this already, but 1 is stdout; 0 is stdin. – Gilles Nov 2 '10 at 18:08
the 0 stdin is news to me :) I learnt something +1 – Stefan Nov 2 '10 at 20:36
up vote 2 down vote accepted
  • You may well expect them to go up to 63 on a typical Linux box.
  • There is (was?) stdlog, but it's rarely used (I believe I never saw one).
  • The order is important: check man bash REDIRECTION.
share|improve this answer
I don't think there's anything standard about 3 going to syslog, it just happens to be the first opened by many programs that already have the standard 0, 1, 2 open. – Gilles Nov 1 '10 at 18:21
@Gilles: actually I was talking about stdlog, not syslog. Too bad, it's not easy to find something viable about that. I believe it was obsoleted long ago. And I must be wrong for putting 3 as it's default number... :-P – alex Nov 2 '10 at 10:13
From light googling, stdlog might have been a FORTRAN thing that never made it into Unix. I didn't find anything like a reference for this, though. – Gilles Nov 2 '10 at 18:07
yeah, that seems pretty much like one of those false memories... – alex Nov 2 '10 at 20:44

The number you need is given by the maximum file descriptor count from the ulimit(1) command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.