[ is an alias for test, which is quite funny I think. 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
[ is an alias for test, which is quite funny I think. 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
Aha, it's: The Linux Documentation Project. Not: Too Long Didn't P*.
FWIW, there are also the shell builtins [[ and ]], via 'man bash'. Somewhat different syntax for the expressions, but otherwise the same as test and [ (which are also bash builtins).
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).