

For example, 2+2 is not correct it should be written as 2 + 2.

There must be spaces between the operators and the expressions. The following points need to be considered while using file test operators − The above script will produce the following result − The following example uses all the file test operators −Īssume a variable file holds an existing file name "/var/"File does not have write permission"Įcho "File does not have execute permission" We have a few operators that can be used to test various properties associated with a Unix file.Īssume a variable file holds an existing file name "test" the size of which is 100 bytes and has read, write and execute permission on − OperatorĬhecks if file is a block special file if yes, then the condition becomes true.Ĭhecks if file is a character special file if yes, then the condition becomes true.Ĭhecks if file is a directory if yes, then the condition becomes true.Ĭhecks if file is an ordinary file as opposed to a directory or special file if yes, then the condition becomes true.Ĭhecks if file has its set group ID (SGID) bit set if yes, then the condition becomes true.Ĭhecks if file has its sticky bit set if yes, then the condition becomes true.Ĭhecks if file is a named pipe if yes, then the condition becomes true.Ĭhecks if file descriptor is open and associated with a terminal if yes, then the condition becomes true.Ĭhecks if file has its Set User ID (SUID) bit set if yes, then the condition becomes true.Ĭhecks if file is readable if yes, then the condition becomes true.Ĭhecks if file is writable if yes, then the condition becomes true.Ĭhecks if file is executable if yes, then the condition becomes true.Ĭhecks if file has size greater than 0 if yes, then condition becomes true.Ĭhecks if file exists is true even if file is a directory but exists.
