gpt4 book ai didi

bash - 为什么 &> 优于 >&?

转载 作者:行者123 更新时间:2023-12-04 14:31:05 28 4
gpt4 key购买 nike

bash 联机帮助页说:

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

为什么首选第一种形式?

最佳答案

作者说&>word>&word是一样的,都等价于>word 2>&1。另外,首选第一种形式。

紧随其后的文字 in the manual说为什么:

When using the second form, word may not expand to a number or ‘-’. If it does, other redirection operators apply (see Duplicating File Descriptors below) for compatibility reasons.

关于bash - 为什么 &> 优于 >&?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33422301/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com