command [ -p ] CommandName [ Argument ... ]
command [ -v | -V ] CommandName
The command command causes the shell to treat the specified command and arguments as a simple command, suppressing shell function lookup.
Normally, when a / (slash) does not precede a command (indicating a specific path), the shell locates a command by searching the following categories:
For example, if there is a function with the same name as a regular built-in, the system uses the function. The command command allows you to call a command that has the same name as a function and get the simple command.
The command -v and command -V commands write to standard output what path name will be used by the shell and how the shell interprets the command type (built-in, function, alias, and so forth). Since the -v and -V flags produce output in relation to the current shell environment, the command command is provided as a Korn shell or POSIX shell regular built-in command. The /usr/bin/command command might not produce correct results, because it is called in a subshell or separate command execution environment,. In the following example the shell is unable to identify aliases, subroutines, or special shell commands:
(PATH=foo command -v) nohup command -v
When the -v or -V flag is specified, the following exit values are returned:
0 | Successful completion. |
>0 | The command specified with the CommandName parameter could not be found or an error occurred. |
When the -v or -V flag is not specified, the following exit values are returned:
Otherwise, the command command returns the exit status associated with the command specified by the CommandName parameter.
cd () { command cd "$@" >/dev/null pwd }
IFS=' ' # The preceding value should be <space><tab><newline>. # Set IFS to its default value \unalias -a # Unset all possible aliases. # Note that unalias is escaped to prevent an alias # being used for unalias. unset -f command # Ensure command is not a user function. PATH="$(command -p getconf _CS_PATH):$PATH" # Put on a reliable PATH prefix. # ...At this point, given correct permissions on the directories called by the PATH environment variable, the script has the ability to ensure that any command it calls is the intended one.
/usr/bin/ksh | Contains the Korn shell command built-in command. |
/usr/bin/command | Contains the command command. |
The ksh command, type command.