Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

Sometimes, in shell scripts, I see like

echo yes 1>&5

I understand it redirect to somewhere, but I would like to know more detail.

And more specifically, what do 1, >, &, 5 mean?

I would be appreciated if you explain them token by token.

Or any pointer that explains.

share|improve this question
The title says 1&>5, but the body of your post says 1>&5. Edit the message and fix it. – Lucio Aug 15 '12 at 2:19
Oops! Edited. Thanks :) – jaeyong Aug 15 '12 at 2:24
up vote 2 down vote accepted

While searching in the internet a bit, i found this.

n>&m    means redirect FD n to the same places as FD m. Eg, 2>&1 means send STDERR to the same place that STDOUT is going to.

STDIN is FD 0, while STDOUT is FD 1, and STDERR is FD 2


File descriptor 5 is sometimes used because it is the lowest numbered file descriptor that was never really used for anything else (FD 4 was /dev/tty on some very old unixes and FD 3 has had various, non-standard, system specific, uses in another Unix). Although since neither 3 or 4 have been used in over 2 decades it is probably just coincidence (or tradition) that you have noticed FD 5 popping up.


As to the reason it is used. By using a file descriptor the script-writer avoids the need to actually write to a file, which could save him time and make the script cleaner (no possibility of accidently leaving around files). Furthermore it lets you do all the cool things with redirecting streams to different locations and so on.

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.