how to check existence of any file in csh script?
From the manpage:
f Plain file
You use it with a if
statement:
if ( -f file.txt ) then echo Existselse echo No such fileendif
Based on this question and your previous question, you seem to be rather clueless as to how csh
syntax works, since you keep using POSIX shell syntax. I would strongly suggest that you either familiarise yourself with the csh
syntax, or just use a POSIX shell (which is probably better for scripting anyway).
In CShell for checking of the existence of a file use -e
option
The name of the file does not have to be "hard coded" into the if statement, butmay be a parameter like this:
if (-e "$filePath") then
Here is a full list of the Cshell file queries.
-e file file merely exists (may be protected from user)-r file file exists and is readable by user-w file file is writable by user-x file file is executable by user-o file file is owned by user-z file file has size 0-f file file is an ordinary file-d file file is a directory