&是什么QUOT;<的/ dev / null的>&安培;的/ dev / null的"在命令的结尾吗? [英] What does "< /dev/null >& /dev/null" at the end of a command do?

查看:154
本文介绍了&是什么QUOT;<的/ dev / null的>&安培;的/ dev / null的"在命令的结尾吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一跑我通过ssh的脚本挂,我发现这个网站它的解决方案:
<一href=\"http://www.snailbook.com/faq/background-jobs.auto.html\">http://www.snailbook.com/faq/background-jobs.auto.html

该网站通过添加这对命令的端解决该问题

 的xterm&LT;的/ dev / null的&GT;&安培;的/ dev / null的&安培;

我想我知道它的一部分的做法,但有人可以帮忙解释一下?

第一部分:

 #标准输入,从/ dev / null的阅读
&LT;的/ dev / null的

第二部分:

 &GT;&安培;的/ dev / null的

这是什么&GT;&安培; 吗?我见过 2 - ;&放大器; 1 这是直接的STDERR到STDOUT,但没有数字,这是否意味着重定向一切的/ dev /空


解决方案

是的,这意味着重定向标准输出和标准错误到/ dev / null的。

信息(bash)的重定向


  

重定向标准输出和标准错误


  
  

击同时允许标准输出(文件描述符1)和
  标准错误输出(文件描述符2)被重定向到文件
  他的名字是WORD与此结构扩展。


  
  

有两种格式重定向标准输出和标准错误:

 &放大器;&GT; WORD

 &GT;&安培; WORD


  
  

这两种形式中,第一个是preferred。这是语义
  相当于

 &GT; WORD 2  - ;&放大器; 1


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 the problem by adding this to the end of the command:

xterm < /dev/null >& /dev/null &

I think I know what part of it does, but can someone help explain?

The first part:

# For stdin, read from /dev/null
< /dev/null

The second part:

>& /dev/null

What does >& do? I've seen 2>&1 which is direct STDERR to STDOUT, but when there are no numbers, does that mean redirect everything to /dev/null?

解决方案

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

这篇关于&是什么QUOT;&LT;的/ dev / null的&GT;&安培;的/ dev / null的&QUOT;在命令的结尾吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆