a.csh是打印某些消息的c脚本。下面这行是做什么的?
source a.csh > &! b.log执行后,b.log文件包含a.csh的输出。但是"&!“的作用是什么呢?
发布于 2018-06-15 22:22:17
>name将标准输出重定向到name;>&将标准输出和标准错误重定向到name,>!覆盖noclobber设置以防止意外覆盖现有文件。
它们可以组合为>&!name,以将标准输出和标准错误重定向到name,从而覆盖noclobber设置。
在您的示例中,>和&!之间的空格使其看起来像是两个不同的运算符,但实际上它只是>&!。
另请参阅man csh (搜索>&):
> name
>! name
>& name
>&! name
The file name is used as standard output. If the file does not
exist then it is created; if the file exists, it is truncated,
its previous contents being lost.
If the shell variable noclobber is set, then the file must not
exist or be a character special file (e.g., a terminal or
`/dev/null') or an error results. This helps prevent acciden‐
tal destruction of files. In this case the `!' forms can be
used to suppress this check. If notempty is given in noclob‐
ber, `>' is allowed on empty files; if ask is set, an
interacive confirmation is presented, rather than an error.
The forms involving `&' route the diagnostic output into the
specified file as well as the standard output. name is
expanded in the same way as `<' input filenames are.(“诊断输出”是标准错误的csh语言)。
https://stackoverflow.com/questions/50877436
复制相似问题