command executes the command name together with
its arguments.
command stops the shell looking for a function defined
within it with the same name as the command name. This may
be used to prevent a function from calling itself recursively (see
``Examples'').
If the command name is a special built-in utility (such as
eval, exec, and set), any variable
assignments do not remain in effect in the environment of the shell
after the utility has finished executing. Also, syntax errors will
not cause the shell to abort.
Using command to execute a command name that is
not a shell function or a special built-in utility is identical to
invoking name in its own right.
You can find out what type of command the current shell thinks
name is by using the options -v or -V.
command accepts the following options:
-p
Use a default value for PATH that finds all the standard
utilities.
-v
Print to the standard output:
the absolute pathname of the command name if
name exists in one of the directories specified by
PATH, or if it is a regular built-in utility associated
with PATH
name itself if it is a special or regular built-in shell
utility, function, or reserved word
an alias definition if name is an alias
nothing if no match to name is found
-V
Prints the same information as -v in a more verbose form
including the assumed category of name:
utilities, regular built-in utilities, and functions found using the
variable PATH
shell functions
aliases
special built-in utilities
regular built-in utilities not associated with PATH
shell reserved words
Exit values
command used with the -v or -V options
has the following exit values:
0
successful completion
>0
name could not be found or an error occurred in
command
Otherwise, command returns:
126
name was found but it could not be executed
127
name could not be found, or an error occurred in
command
Any other value is the exit value returned by the command
name.
Examples
Define a function cd() that prints the new working
directory (note that command prevents this function from
being recursive):
cd() {
command cd "$@" > /dev/null
pwd
}
Stop a special built-in utility from aborting the shell; for example
when trying to redirect the standard output to a file that has the
wrong permissions:
command exec > file_with_mode_0000
Execute
getconf(C)
to get the default system path without assuming that PATH
is already set up: