if [ -f "/etc/passwd" ]; then
echo "File exists"
fi
if [ -d "$dir" ]; then
echo "Is a directory"
fi
if [ -r "$file" ] && [ -w "$file" ]; then
echo "Readable and writable"
fi
if [ -z "$var" ]; then
echo "Variable is empty"
fi
if [ "$USER" = "root" ]; then
echo "Running as root"
fi
if [ "$a" != "$b" ]; then
echo "Strings differ"
fi
# NOT
if [ ! -f "$file" ]; then
echo "File not found"
fi
# AND
if [ -f "$file" -a -r "$file" ]; then
echo "File exists and is readable"
fi
# OR
if [ -z "$a" -o -z "$b" ]; then
echo "At least one is empty"
fi
# Preferred over -a and -o
if [ -f "$file" ] && [ -r "$file" ]; then
echo "File exists and readable"
fi
if [ -z "$a" ] || [ -z "$b" ]; then
echo "At least one is empty"
fi