Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
[ is an alias for test, which is quite funny I think. :D Try: man [ it will bring up the manual for test. It gives a bit more syntactically pleasing look if used in a script.

Code:
if [ -f $1 ]
then
    echo file
else if [ -d $1 ]
    echo directory
fi
 
test and [ are /bin utilities, which would work in all shells
[[ ... ]] is a bash (and ksh) built in
 
test and [ are /bin utilities, which would work in all shells
[[ ... ]] is a bash (and ksh) built in

FWIW, test and [ are bash builtins. They also exist as /bin tools, but bash (like other shells) searches its builtins first, unless the command contains a slash.

Try this:
Code:
type [ test
type is another builtin, otherwise similar to which (which isn't a builtin in bash).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.