加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – >&是什么意思?

发布时间:2020-12-15 09:17:14 所属栏目:安全 来源:网络整理
导读:我对这个表达感到困惑: gcc -c -g program.c compiler.txt 我知道 filename会将stdout和stderr重定向到文件filename。但在这种情况下,符号是在大于号后。它看起来像其形式M N,其中M和N是文件描述符。 在上面的代码段中,M = 1和N =’compiler.txt’?这是
我对这个表达感到困惑:
gcc -c -g program.c >& compiler.txt

我知道&> filename会将stdout和stderr重定向到文件filename。但在这种情况下,&符号是在大于号后。它看起来像其形式M>& N,其中M和N是文件描述符。

在上面的代码段中,M = 1和N =’compiler.txt’?这是如何不同于:

gcc -c -g program.c > compiler.txt     (ampersand removed)

我的理解是每个打开的文件与大于2的文件描述符相关联。这是正确的吗?

如果是这样,是一个文件名可以与它的文件描述符互换,作为重定向的目标?

这与&>相同。从bash手册页:

Redirecting Standard Output and Standard Error
This construct 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.

06000

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读