What does “< /dev/null >& /dev/null” at the end of a command do?

前端 未结 3 511
逝去的感伤
逝去的感伤 2020-12-29 12:09

One of the scripts I run over ssh was hanging and I found a solution for it on this site: http://www.snailbook.com/faq/background-jobs.auto.html

The site resolves th

相关标签:
3条回答
  • 2020-12-29 12:32

    Googling for 'stream redirection >& ' will let you find http://tldp.org/LDP/abs/html/io-redirection.html

    which, among other things, tells you

      >&j
    
      # Redirects, by default, file descriptor 1 (stdout) to j.
      # All stdout gets sent to file pointed to by j.
    

    Maybe this already helps.

    Or search the help of standard unix shells, like bash, for stream redirection.

    Rgds,

    Thomas

    0 讨论(0)
  • 2020-12-29 12:47

    With ssh another way (to achieve what you probably want) is to pass the -f flag, i.e.

    ssh -X -f your.host.org xterm
    
    0 讨论(0)
  • 2020-12-29 12:56

    Yes, this means redirect both stdout and stderr to /dev/null.

    From info "(bash)Redirections":

    Redirecting Standard Output and Standard Error

    Bash allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of WORD with this construct.

    There are two formats for redirecting standard output and standard error:

    &>WORD
    

    and

    >&WORD
    

    Of the two forms, the first is preferred. This is semantically equivalent to

    >WORD 2>&1
    
    0 讨论(0)
提交回复
热议问题