对 tcsh/csh 中不存在的文件使用“>>”重定向运算符

max*_*ywb 3 bash shell shell-script tcsh

我正在编写 tcsh 脚本,我想附加到一个日志文件,但是如果在附加到它之前日志文件不存在,我会收到一个错误(在下面重现)。在 bash 中,如果文件不存在,则会创建该文件。tcsh 是否支持此功能,或者我是否必须在追加之前确保该文件存在?

有没有办法>>在 tcsh 中使用类似于 bash的运算符?

$ echo something >> file_that_does_not_exist
file_that_does_not_exist: No such file or directory.
Run Code Online (Sandbox Code Playgroud)

Sco*_*ott 5

尝试

command >>! log_file_name

或者这也用于重定向 stderr

command >>&! log_file_name

例如,请参阅csh(1)和/或tcsh(1)此处此处