Skip to main content
deleted 1 character in body
Source Link
Luca
  • 13
  • 3

I've found mostly confusing the syntax about closing file descriptors. Taking as example: n>&-, i'm closing a file descriptor called n, i'm right ?

But i knew that if i want redirect somenthingsomething into another file descriptor, i must do that this way n>&1, so the & is used as marker for file descriptors, only when >, or others redirection commands are used, and also this should be correct, right ?

Futhermore, - symbol can be used for redirection from/to stdin or stdout as into: cat -

So taking into account the rules said above, why n>&- should close a file descriptor ? It seems like a redirection to stdin...

PS: For references i've used http://tldp.org/LDP/abs/html/io-redirection.html and http://tldp.org/LDP/abs/html/special-chars.html

I've found mostly confusing the syntax about closing file descriptors. Taking as example: n>&-, i'm closing a file descriptor called n, i'm right ?

But i knew that if i want redirect somenthing into another file descriptor, i must do that this way n>&1, so the & is used as marker for file descriptors, only when >, or others redirection commands are used, and also this should be correct, right ?

Futhermore, - symbol can be used for redirection from/to stdin or stdout as into: cat -

So taking into account the rules said above, why n>&- should close a file descriptor ? It seems like a redirection to stdin...

PS: For references i've used http://tldp.org/LDP/abs/html/io-redirection.html and http://tldp.org/LDP/abs/html/special-chars.html

I've found mostly confusing the syntax about closing file descriptors. Taking as example: n>&-, i'm closing a file descriptor called n, i'm right ?

But i knew that if i want redirect something into another file descriptor, i must do that this way n>&1, so the & is used as marker for file descriptors, only when >, or others redirection commands are used, and also this should be correct, right ?

Futhermore, - symbol can be used for redirection from/to stdin or stdout as into: cat -

So taking into account the rules said above, why n>&- should close a file descriptor ? It seems like a redirection to stdin...

PS: For references i've used http://tldp.org/LDP/abs/html/io-redirection.html and http://tldp.org/LDP/abs/html/special-chars.html

edited tags
Link
user147505
user147505
Source Link
Luca
  • 13
  • 3

Syntax confusion about closing file descriptors

I've found mostly confusing the syntax about closing file descriptors. Taking as example: n>&-, i'm closing a file descriptor called n, i'm right ?

But i knew that if i want redirect somenthing into another file descriptor, i must do that this way n>&1, so the & is used as marker for file descriptors, only when >, or others redirection commands are used, and also this should be correct, right ?

Futhermore, - symbol can be used for redirection from/to stdin or stdout as into: cat -

So taking into account the rules said above, why n>&- should close a file descriptor ? It seems like a redirection to stdin...

PS: For references i've used http://tldp.org/LDP/abs/html/io-redirection.html and http://tldp.org/LDP/abs/html/special-chars.html