做什么 >!和 >>!在 tcsh 中做 [英] What do >! and >>! do in tcsh

查看:73
本文介绍了做什么 >!和 >>!在 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 写入 file
  • cmd >如果 file 存在,file 将失败
  • cmd >>如果 file 存在
  • ,file 会将 stdout 附加到 file
  • cmd >>如果 file 不存在,file 将失败
  • cmd >!file 会将 stdout 写入 file,覆盖任何现有文件
  • cmd >>!file 会将 stdout 附加到 file,如果文件不存在则创建该文件
  • cmd > file will write stdout to file if file does not exist
  • cmd > file will fail if file exists
  • cmd >> file will append stdout to file if file exists
  • cmd >> file will fail if file does not exist
  • cmd >! file will write stdout to file, overwriting any existing file
  • cmd >>! file will append stdout to file, creating the file if it does not already exist

如果 noclobbernot 设置,那么 !没有效果:

If noclobber is not set then the ! has no effect:

  • cmd >file 会将 stdout 写入 file,覆盖任何现有文件
  • cmd >>file 会将 stdout 附加到 file
  • cmd >!file 会将 stdout 写入 file,覆盖任何现有文件
  • cmd >>!file 会将 stdout 附加到 file
  • cmd > file will write stdout to file, overwriting any existing file
  • cmd >> file will append stdout to file
  • cmd >! file will write stdout to file, overwriting any existing file
  • cmd >>! file will append stdout to file

这篇关于做什么 >!和 >>!在 tcsh 中做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆