top | item 47173073

(no title)

ElijahLynn | 3 days ago

I found the explanation useful, about "why" it is that way. I didn't realize the & before the 1 means to tell it is the filedescriptor 1 and not a file named 1.

discuss

order

weavie|3 days ago

I get the ocassional file named `1` lying around.

hrmtst93837|2 days ago

The distinction between file descriptors and regular files trips up many people at first. Recognizing that `&` signifies a file descriptor clears up the confusion about the syntax.

LtWorf|3 days ago

It's an operator called ">&", the 1 is the parameter.

WJW|3 days ago

Well sure, but surely this takes some inspiration from both `&` as the "address of" operator in C as well as the `>` operator which (apart from being the greater-than operator) very much implies "into" in many circumstances.

So `>&1` is "into the file descriptor pointed to by 1", and at the time any reasonable programmer would have known that fd 1 == STDOUT.