做什么 >!和 >>!在 tcsh 中做 [英] What do >! and >>! do in tcsh
问题描述
在普通的 bash 重定向中 >
将标准输出重定向到一个文件,当它存在时覆盖,>>
将标准输出重定向到一个文件,当它存在时附加.
In normal bash redirection >
redirecting standard output to a file, overwriting when it exists and >>
redirecting standard output to a file, appending when it exists.
在 tcsh (c shell) 脚本中,我发现使用了运算符 >>!
>>!
.这个运营商是做什么的?tcsh 也有 >
和 >>
操作符,那么有什么区别呢?
In a tcsh (c shell) script I found the operators >!
>>!
being used. What do this operators do? tcsh does also have the >
and >>
operators, so what is the difference?
推荐答案
在 tcsh 重定向中!符号表示即使设置了 noclobber
也会覆盖现有文件.
In tcsh redirection the ! symbol means overwrite the existing file even if noclobber
is set.
换句话说,如果设置了 noclobber,则:
In other words, if noclobber is set then:
cmd >如果 file 不存在,file
会将stdout
写入 filecmd >如果 file 存在,file
将失败cmd >>如果 file 存在
,file 会将 cmd >>如果 file 不存在,file
将失败cmd >!file
会将stdout
写入 file,覆盖任何现有文件cmd >>!file
会将stdout
附加到 file,如果文件不存在则创建该文件
stdout
附加到 filecmd > file
will writestdout
to file if file does not existcmd > file
will fail if file existscmd >> file
will appendstdout
to file if file existscmd >> file
will fail if file does not existcmd >! file
will writestdout
to file, overwriting any existing filecmd >>! file
will appendstdout
to file, creating the file if it does not already exist
如果 noclobber
是 not 设置,那么 !没有效果:
If noclobber
is not set then the ! has no effect:
cmd >file
会将stdout
写入 file,覆盖任何现有文件cmd >>file
会将stdout
附加到 filecmd >!file
会将stdout
写入 file,覆盖任何现有文件cmd >>!file
会将stdout
附加到 file
cmd > file
will writestdout
to file, overwriting any existing filecmd >> file
will appendstdout
to filecmd >! file
will writestdout
to file, overwriting any existing filecmd >>! file
will appendstdout
to file
这篇关于做什么 >!和 >>!在 tcsh 中做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!