首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"&!“在csh中

"&!“在csh中
EN

Stack Overflow用户
提问于 2018-06-15 22:18:24
回答 1查看 122关注 0票数 0

a.csh是打印某些消息的c脚本。下面这行是做什么的?

代码语言:javascript
复制
source a.csh > &! b.log

执行后,b.log文件包含a.csh的输出。但是"&!“的作用是什么呢?

EN

回答 1

Stack Overflow用户

发布于 2018-06-15 22:22:17

>name将标准输出重定向到name>&将标准输出和标准错误重定向到name>!覆盖noclobber设置以防止意外覆盖现有文件。

它们可以组合为>&!name,以将标准输出和标准错误重定向到name,从而覆盖noclobber设置。

在您的示例中,>&!之间的空格使其看起来像是两个不同的运算符,但实际上它只是>&!

另请参阅man csh (搜索>&):

代码语言:javascript
复制
   > 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语言)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50877436

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档