Michael Williams wrote: > if [-d $i] That is not the correct syntax. The [ is a shell builtin, not a shell metacharacter. Shell metacharacters do not need to be separated by whitespace but the test program needs to be apart or it won't be parsed right. That is why you are seeing "[-d" not found. It is not a parenthesis as in some programming languages. The [ is a synonym for the "test" operator. It is a command like grep, sed, awk, etc.
[ -d /tmp ] && echo /tmp is a dir Do it this way. if [ -d "$i" ] Note that you should quote the argument to protect against whitespace there. Bob