Previous Table of Contents Next

Test and C Shell Built-In Test

What Is Tested Test Command csh Built-In
file is block device -bfile N/A
file is character device -cfile N/A
file is directory -dfile -dfile
file or directory exists N/A -efile
file is file -ffile -ffile
file has set-group-id bit set -gfile N/A
file has sticky bit set -kfile N/A
file is owned by executing user N/A -ofile
file is a named pipe -pfile N/A
current user can read file -rfile -rfile
file exists and has size >0 -sfile N/A
n is a terminal file descriptor -tn N/A
file has set-user-id bit set -ufile N/A
current user can write to file -wfile -wfile
current user can execute file -xfile N/A
file has zero size N/A -zfile
string is NULL -zstring string== ""
string is NOT NULL string!= "" -nstring,string
strings are equal string=string string==string
strings are not equal string!=string string!=string
string matches filename wildcard pattern N/A string=~pattern
string does not match filename wildcard pattern N/A string!~pattern
num1 is equal to num2 num1-eqnum2 num1==num2
num1 is not equal to num2 num1-nenum2 num1|=num2
num1 is less than num2 num1-ltnum2 num1<num2
num1 is less than or equal to num2 num1-lenum2 num1<=num2
num1 is greater than num2 num1-gtnum2 num1>num2
num1 is greater than or equal to num2 num1-genum2 num1>=num2
logical AND -a &&
logical OR -o ||
logical NEGATION ! !!

Bourne Shell Mathematical Operators

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder

C Shell Mathematical Operators

Syntax Description
@variable = (expression) Set value of variable equal to the expression.
@variable += (expression) Addition.
@variable -= (expression) Subtraction.
@variable *= (expression) Multiplication.
@variable /= (expression) Division.
@variable ++ Add 1.
@variable - - Subtract 1.

Previous Table of Contents Next