Text-only | Table of Contents (frame/ no frame) |
(17) Conditional Tests (contd.) |
![]() ![]() ![]() |
$variable -eq number
$variable -ne number
-lt
= less than, -le
= less than or equal,
-gt
= greater than, -ge
= greater than or equal
$variable = pattern
file1 -nt file2
-ot
= older than
file1 -ef file2
!
operator, and combined with boolean
AND and OR operators using the syntax:
conditional -a conditional, conditional -o conditional
test
and [
conditional && conditional, conditional || conditional
[[ ... ]]
Examples:
if [[ -x /usr/local/bin/lserve && \ -w /var/logs/lserve.log ]]; then /usr/local/bin/lserve >> /var/logs/lserve.log & fi pwent=`grep '^richard:' /etc/passwd` if [ -z "$pwent" ]; then echo richard not found fi
cond-tests2.src last modified Mar 11, 2005 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |