Use ">>" Redirection Operator for Non-Existent File In tcsh/csh

3

I'm writing tcsh scripts and I would like to append to a log file, but if the log file doesn't exist before appending to it, I get an error (reproduced below). In bash the file gets created if it doesn't already exist. Does tcsh support this feature or do I have to ensure that the file exists before appending to it?

Is there a way to use the >> operator in tcsh similar to bash?

$ echo something >> file_that_does_not_exist
file_that_does_not_exist: No such file or directory.

maxywb

Posted 2013-11-25T17:15:16.303

Reputation: 135

Answers

5

Try

command >>! log_file_name

Or this for redirecting stderr as well

command >>&! log_file_name

See csh(1) and/or tcsh(1), here and here, for example.

Scott

Posted 2013-11-25T17:15:16.303

Reputation: 17 653