#Bash 的 command 命令
command [OPTION]... CMD [ARG]...
功能
执行简单命令或显示有关命令的信息。
Bash 查找命令的顺序为
别名 > 函数 > 内置命令 > 可执行文件;此命令跳过别名和函数,直接执行命令。
类型
Bash 内置命令。
参数
OPTION- 选项:-p- 将PATH环境变量设为默认值,以确保能够找到所有标准实用程序-v- 打印命令的描述-V- 打印命令的详细描述
CMD- 要执行的命令ARG-CMD的参数列表
#示例
查看命令描述
$ command -v ls # 打印 ls 命令的描述
alias ls='ls --color=auto'
$ command -V ls # 打印 ls 命令的详细描述
ls is aliased to `ls --color=auto'
执行命令
$ ls # 别名:ls --color=auto
1.txt 2.txt 3.txt dir1 dir2
$ command ls # 直接执行 ls 命令
1.txt 2.txt 3.txt dir1 dir2
#相关命令
| 命令 | 说明 |
|---|---|
| builtin | 忽略别名、函数和可执行文件,直接执行内置命令 |
命令前加
\前缀可以忽略别名,执行命令。
#手册
command: command [-pVv] command [arg ...]
Execute a simple command or display information about commands.
Runs COMMAND with ARGS suppressing shell function lookup, or display
information about the specified COMMANDs. Can be used to invoke commands
on disk when a function with the same name exists.
Options:
-p use a default value for PATH that is guaranteed to find all of
the standard utilities
-v print a description of COMMAND similar to the `type' builtin
-V print a more verbose description of each COMMAND
Exit Status:
Returns exit status of COMMAND, or failure if COMMAND is not found.