LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

command

execute commands bypassing shell functions

TLDR

Run a command ignoring shell functions
$ command [ls]
copy
Check if a command exists (POSIX-portable way)
$ command -v [git] && echo "git is installed"
copy
Get the path of a command
$ command -v [python3]
copy
Describe a command's type
$ command -V [cd]
copy
Run external command when function exists with same name
$ ls() { command ls --color=auto "$@"; }
copy

SYNOPSIS

command [-pVv] command [arguments]

DESCRIPTION

command is a shell builtin that executes a command, bypassing shell functions with the same name. This is essential when writing wrapper functions that need to call the original command they're wrapping.With -v, it prints how the command would be resolved: the path for external commands, the definition for aliases, or indication for builtins and functions. This is the POSIX-portable way to check if a command exists (preferred over which).The -V option provides verbose output describing what type of command it is (builtin, function, alias, or external) and where it's defined.

PARAMETERS

-v

Print the pathname or alias that would be used (like which).
-V
Verbose description of command type.
-p
Use default PATH to find command, ignoring custom PATH.

CAVEATS

command is a shell builtin, not an external program. Behavior may vary slightly between shells (bash, zsh, dash). The -v option returns success (0) if the command exists, making it ideal for conditional checks. Unlike which, it handles builtins and functions correctly.

HISTORY

The command builtin was specified in POSIX.2 (1992) to provide a standard way to bypass function lookup and check command availability. It was designed to replace non-portable utilities like which for determining command paths. The builtin is available in all POSIX-compliant shells including bash, dash, zsh, and ksh.

SEE ALSO

which(1), type(1), whence(1), builtin(1), hash(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid