Alb*_*era 1 linux bash shell-script
如果我command
在我的终端上输入,我不会得到“找不到命令”,并且退出代码是 0。我认为这意味着command
实际上在 bash 上做了一些事情。
此外,command -h
返回:
bash: command: -h: invalid option
command: usage: command [-pVv] command [arg ...]
Run Code Online (Sandbox Code Playgroud)
它是干什么用的?
来自help command
:
$ help command
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.
Run Code Online (Sandbox Code Playgroud)
作为更一般的说明,而不是仅仅-h
在您不知道命令的作用时使用,您应该尝试:
type -a command
Run Code Online (Sandbox Code Playgroud)
在这种情况下,它会告诉你它是一个内置的 shell。
help command
Run Code Online (Sandbox Code Playgroud)
对 shell 内置函数有好处。对于其他命令(实际上也适用于 shell 内置命令),请尝试
man somecommand
Run Code Online (Sandbox Code Playgroud)
另外,-h
是不是一定的“帮助”选项。如果您不知道命令的作用,那可能不是一个安全的假设。更安全的是--help
。
somecommand --help
Run Code Online (Sandbox Code Playgroud)
(常用命令这里-h
是一个有效的选择,但确实不是意味着“帮助”是ls
,free
,df
,du
。的这些都是仅供参考,但前提是-h
仅会平均“帮助”是一个危险的假设。)
归档时间: |
|
查看次数: |
2610 次 |
最近记录: |