There is a special class of C-shell operator that lets you test the
properties of a file. A file operator is used in comparison
expressions of the form if (file_operator file) then.
A list of file operators is tabulated below.
The most common usage is to test for a file's existence. The following only runs cleanup if the first argument is an existing file.
# Check that the file given by the first # argument exists before attempting to # use it. if ( -e $1 ) then cleanup $1 endif
Here are some other examples.
# Remove any empty directories. if ( -d $file && -z $file ) then rmdir $file # Give execute access to text files with a .csh extension. else if ( $file:e == "csh" && -f $file ) then chmod +x $file endif