help命令和help选项
- 1.命令的--help选项
- 2.help命令
1.命令的--help选项
回到顶部例如想要快速查看pwd命令的帮助信息,直接使用--help选项:
[peter@initroot ~]$ pwd --help
pwd: pwd [-LP]
Print the name of the current working directory.
Options:
-L print the value of $PWD if it names the current working
directory
-P print the physical directory, without any symbolic links
By default, `pwd' behaves as if `-L' were specified.
Exit Status:
Returns 0 unless an invalid option is given or the current directory
cannot be read.
可以看到上面给出了pwd的常见用法、命令功能说明,命令的选项以及命令的退出状态。通过--help选项,可以快速的了解命令的使用方法。
2.help命令
回到顶部其实help本身也是shell的内置命令,"help命令是bash shell的help".
用type help可以看到help是一条shell内置命令:
[peter@initroot ~]$ type help help is a shell builtincd是一条内置命令,可以在命令行下输入help cd查看cd的帮助信息:
[peter@initroot ~]$ help cd
一般help的输出和--help选项的输出是一样的,区别是help只能用于shell内置命令,而--help几乎可以用于所有命令,并不区分内置命令和外置命令。例如ls命令是一条外置命令,可以使用ls --help命令查看ls的基本用法,但是用help命令查看的话:
[peter@initroot ~]$ help ls bash: help: no help topics match `ls'. Try `help help' or `man -k ls' or `info ls'.help告诉我们找不到ls命令的相关帮助主题,因为ls不是shell的内置功能。
help建议我们使用help help查看help自己的帮助信息。
或者使用man或者info查看ls命令的帮助信息。
initroot编辑整理,转载请注明www.initroot.com
100次点赞
100次阅读