The file inspector, compressed to its elif chain
The file inspector, compressed to its elif chain
Answer
if [ ! -e "$f" ]; then echo "missing" elif [ -d "$f" ]; then echo "directory" elif [ -s "$f" ]; then echo "non-empty file" else echo "empty or special" fi
Semicolons let then sit on the same line as the test; the multi-line form in the prose means exactly the same thing. The existence test has to come first because every later operator assumes the name resolves.
S&K 3e ch12 §12.6.1, §12.6.6