You can test many ways in sh, ksh, bash using different delimiters: [] () (()) [[]]
- () is same as cmd, a subshell, and the return (exit) 0 is true.
- Basically, [ is test, see man test.
- ksh/bash (()) are very nice for math, logic, numbers and bits, with operators + - * / % && & || | () and such like C.
- bash [[]] allows regex testing.
Using builtins is much cheaper than fork/exec a command or two, and the test bits are now built in, so to find a file, it is far simpler to [ -f file ] than ( ls | grep file ), which is two fork/exec and a pipe. For the former, the shell just does an access() call.
Polling files is a sad way to flow control jobs. It harkens back to the days of tape. The shell has better ways to keep track of children, e.g., (proc1&proc2&proc3&wait;proc4), and many times pipes make flow control and intermediate flat files unnecessary while reducing latency by pipeline parallelism: proc4 <(proc1) <(proc2) <(proc3)