0

This question already has an answer here:

nohup grunt server:debug >grunt.out 2>&1 <&- &

I have a nohup command that ends with <&- . What does this direction do? Can some explain with pointers. I did search google for examples, but could not find one which explained about <&- and is this really required?

marked as duplicate by muru, garethTheRed, Jeff Schaller, Anthon, derobert May 11 '16 at 21:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

Rather search through manual pages (man bash is your friend). Such special characters are hard to find in google. Basically you end up with this section:

Duplicating File Descriptors

The redirection operator

[n]<&word

is used to duplicate input file descriptors. If word expands to one or more digits, the file descriptor denoted by n is made to be a copy of that file descriptor. If the digits in word do not specify a file descriptor open for input, a redirection error occurs. If word evaluates to -, file descriptor n is closed. If n is not specified, the standard input (file descriptor 0) is used.

So in the other words, <&- means, that it basically closes stdin, so the program running under nohop really can not read anything from there.

1

May be this list helps:

<&(Digit) Duplicates standard input from the file descriptor specified by the Digit parameter

>&(Digit) Duplicates standard output in the file descriptor specified by the Digit parameter

<&- Closes standard input

>&- Closes standard output

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