# test / [: file types, string and numeric forms, error statuses. : >f; mkdir d; ln -s f link; ln -s nowhere dangling; mkfifo fifo for op in -e -f -d -h -L -p -s -b -c -S; do for file in f d link dangling fifo /dev/null nope; do # A directory's size is 0 on z/OS, and POSIX leaves the size of one # to the system, so -s is only tested on files. case $op/$file in -s/d) continue ;; esac [ $op $file ] && printf '%s %s\n' "$op" "$file" done done echo data >f [ -s f ] && echo nonempty [ f -ef link ] && echo same-file; [ f -ef d ] || echo different : >old; sleep 1.1; : >new [ new -nt old ] && echo newer; [ old -ot new ] && echo older [ old -nt new ] || echo not-newer test -t 0 /dev/null; echo "no-bracket=$?" [ 1 -eq x ] 2>/dev/null; echo "bad-int=$?" [ a b c d e ] 2>/dev/null; echo "junk=$?" [ \( a = a ] 2>/dev/null; echo "no-close=$?" [ -f ]; echo "lone-f=$?" [ a -zz b ] 2>/dev/null; echo "bad-op=$?" test; echo "test-empty=$?"