Go to: Synopsis. Return value. Flags. MEL examples.
filetest [-L] [-b] [-c] [-d] [-e] [-f] [-g] [-h] [-k] [-l] [-p] [-r] [-s] [-u] [-w] [-x] [-z]
string
filetest is NOT undoable, NOT queryable, and NOT editable.
This is a file access and type checking command. It evaluates a test based on a single flag given to it and returns 1 if the value is true; otherwise, 0. Filetest also returns 0 if the test is invalid. When permissions are tested, the effective user ID of the process is used. The unary negation operator, "!", may precede the test. Special Note: If you test a file you own (the -r, -w, or -x tests), but the permission tested does not have the owner bit set, a non-zero (false) exit status will be returned even though the file may have the group or other bit set for that permission. The correct exit status will be set if you are super-user. If more than one test is specified, only the first test is executed; the others are ignored. Note:int | Test result |
Long name (short name) | Argument types | Properties | ||
---|---|---|---|---|
-r(-r)
|
|
|||
|
||||
-l(-l)
|
|
|||
|
||||
-w(-w)
|
|
|||
|
||||
-x(-x)
|
|
|||
|
||||
-f(-f)
|
|
|||
|
||||
-d(-d)
|
|
|||
|
||||
-h(-h)
|
|
|||
|
||||
-c(-c)
|
|
|||
|
||||
-b(-b)
|
|
|||
|
||||
-p(-p)
|
|
|||
|
||||
-u(-u)
|
|
|||
|
||||
-g(-g)
|
|
|||
|
||||
-k(-k)
|
|
|||
|
||||
-s(-s)
|
|
|||
|
||||
-L(-L)
|
|
|||
|
||||
-e(-e)
|
|
|||
|
||||
-z(-z)
|
|
|||
|
Flag can appear in Create mode of command | Flag can appear in Edit mode of command |
Flag can appear in Query mode of command | Flag can be used more than once in a command. |
// Test whether the temp directory exists // string $tmpDir = `internalVar -userTmpDir`; filetest -d $tmpDir; // Result: 1 // // The following will fail because the temp dir is not a regular file // filetest -f $tmpDir; // Result: 0 //