2019-03-31 09:05:09 +00:00
.. _cmd-command:
2018-12-17 01:39:33 +00:00
command - run a program
2019-01-03 04:10:47 +00:00
=======================
2018-12-17 01:39:33 +00:00
2018-12-18 01:58:24 +00:00
Synopsis
--------
2018-12-16 21:08:41 +00:00
2021-12-09 12:45:10 +00:00
`` command `` [ *OPTIONS* ] [**COMMAND** [*ARG* ...]]
2018-12-16 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Description
2019-01-03 04:10:47 +00:00
-----------
2018-12-16 21:08:41 +00:00
2018-12-19 20:02:45 +00:00
`` command `` forces the shell to execute the program `` COMMANDNAME `` and ignore any functions or builtins with the same name.
2018-12-16 21:08:41 +00:00
The following options are available:
2021-12-09 12:45:10 +00:00
**-a** or **--all**
Prints all *COMMAND* found in :envvar: `PATH` , in the order found.
2018-12-16 21:08:41 +00:00
2021-12-09 12:45:10 +00: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 21:08:41 +00:00
2021-12-09 12:45:10 +00: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 21:08:41 +00:00
2021-12-12 08:17:16 +00: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 21:08:41 +00:00
2018-12-19 02:44:30 +00:00
Examples
2019-01-03 04:10:47 +00:00
--------
2018-12-16 21:08:41 +00:00
2021-12-12 08:17:16 +00: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 12:45:10 +00:00
| `` command -q git; and command git log `` runs `` git log `` only if `` git `` exists.