Hamilton LaboratoriesHamilton C shell 2012User guideLanguage reference

File system tests

Oregon Coast

File system tests
Previous | Next


See also


The file system operators each take a single operand word. This first set all return 1 (true) or 0 (false).

Operator True if

Archive bit set


File or directory is compressed

-D   -d



Hidden file or directory


Read-only file or directory


System file or directory


File or directory exists


Ordinary File


Ownership (Same as existence on a FAT file system)


Readable (Same as ordinary file on a FAT file system)


Writable (Not read-only and not a directory)


Executable (Has a .csh, .exe, .com or .cmd extension and, if it's an .exe or a .com file, appears to be a valid binary executable.)


Zero-length file

The -t and -s operators return timestamps and sizes.

Operator Returns

Timestamp in the 24-hour local time formatted as a character string of the form, YYYY-MM-DD hh:mm:ss, e.g., 2012-11-25 17:35:26. If the operand doesn't exist or doesn't have a timestamp (as is the case for C:\), -t returns null; this is not an error.


Size in bytes if the operand exists and is a file, otherwise null.


The file system operators are all prefix operators. Each takes a single operand, which is interpreted as a word, not an expression, and may involve wildcarding. If wildcarding produces more than one match, the test is done on the first one. For example:

if (-d $a) then echo $a is a directory end

See also

Expression operators
Tutorial: Words versus expressions
Tutorial: Wildcarding
Tutorial: Expressions

Previous | Next

Getting started with Hamilton C shell

Hamilton C shell, as it first wakes up.

Getting started with Hamilton C shell

A first few commands.

You can set the screen colors to your taste.

You can set the screen colors to your taste.