if tagged posts

Korn Shell (KSH) Command | if Test Parameters

if/Test Statement

test -e file
[ -e file ]
[[ -e file ]]

x=2
test $x -eq 1
[ $x -eq 2 ]
[[ $x -eq 3 ]]

File Test Operators

File status can be examined using several operators.

Parameter:     Meaning
-s file     size greater than zero
-r file      exists and is readable
-w file      exists and is writable
-x file      exists and is executable
-u file      exists and has the SUID bit set
-g file       exists and has the SGID bit set
-k file      exists and has the SVTX sticky bit set
-e file       exists
-f file      exists and is an ordinary file
-d file      exists and is a directory
-c file      exists as a character special file
-b file      exists and is a named pipe file
-p file      exists and is a named pipe file
-L file    ...

Read More