2019-03-31 11:05:09 +02:00
.. _cmd-command:
2018-12-16 17:39:33 -08:00
command - run a program
2019-01-02 20:10:47 -08:00
=======================
2018-12-16 17:39:33 -08:00
2018-12-17 17:58:24 -08:00
Synopsis
--------
2018-12-16 13:08:41 -08:00
2021-12-09 04:45:10 -08:00
`` command `` [ *OPTIONS* ] [**COMMAND** [*ARG* ...]]
2018-12-16 13:08:41 -08:00
2018-12-18 18:44:30 -08:00
Description
2019-01-02 20:10:47 -08:00
-----------
2018-12-16 13:08:41 -08:00
2018-12-19 12:02:45 -08:00
`` command `` forces the shell to execute the program `` COMMANDNAME `` and ignore any functions or builtins with the same name.
2018-12-16 13:08:41 -08:00
The following options are available:
2021-12-09 04:45:10 -08:00
**-a** or **--all**
Prints all *COMMAND* found in :envvar: `PATH` , in the order found.
2018-12-16 13:08:41 -08:00
2021-12-09 04:45:10 -08:00
**-q** or **--query**
Silence output and print nothing, setting only exit status.
Implies **--search** .
For compatibility, this is also **--quiet** (deprecated).
2018-12-16 13:08:41 -08:00
2021-12-09 04:45:10 -08:00
**-v** (or **-s** or **--search** )
Prints the external command that would be executed, or prints nothing if no file with the specified name could be found in :envvar: `PATH` .
2018-12-16 13:08:41 -08:00
2021-12-12 00:17:16 -08:00
With the **-v** option, `` command `` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 127 if no commands could be found. **--quiet** used with **-v** prevents commands being printed, like `` type -q `` .
2018-12-16 13:08:41 -08:00
2018-12-18 18:44:30 -08:00
Examples
2019-01-02 20:10:47 -08:00
--------
2018-12-16 13:08:41 -08:00
2021-12-12 00:17:16 -08:00
| `` command ls `` executes the `` ls `` program, even if an `` ls `` function also exists.
| `` command -s ls `` prints the path to the `` ls `` program.
2021-12-09 04:45:10 -08:00
| `` command -q git; and command git log `` runs `` git log `` only if `` git `` exists.