'How can I force redirect using > in csh to clobber existing file?
OSTYPE=linux
OS_KERNEL_VERSION=3.10.0
csh
When I try to clobber an existing file using redirect ">" I get an error... "File exists."
% date > the.log
% echo $?
0
% date > the.log
the.log: File exists.
% echo $?
1
How can I simply force the clobber of "the.log" without getting the error ?
Update: This appears to be happening on one server but not others. So it's a server specific thing... some sort of config setting ?
Solution 1:[1]
In linux you cannot have two files with same name,once check using ls commadn,if you dont want error give % date > the.log 2>&1 for both error and sucess to fall to log file
Solution 2:[2]
Thanks Harish for the reply. But vgersh99 got it right (the 2nd time). For csh, you need the '!'. Something to do with a noclobber setting in the shell.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | harish chilukuri |
| Solution 2 | daveg |
