jha*_*ott 11 bash shell command-line
如果我在脚本中看到一个我不知道的命令并输入(例如),man pushd或者man umask我看到内置命令的手册页。我知道我可以做man bash并滚动以找到该内置命令的帮助,或者我可以打开浏览器并转到更易于搜索的在线 bash 手册页,但是有没有更简单的方法来获取手册页单个内置命令直接在命令行上?
mpy*_*mpy 12
也许你喜欢有一些直接跳到内置函数的包装函数:
man -P "less +/\ \ \ pushd" bash
Run Code Online (Sandbox Code Playgroud)
-P告诉 man 使用 less 作为寻呼机(可能是大多数系统上的默认设置),但直接将搜索传递给它。您需要在搜索字符串之前添加一些空格以跳过文本中的命中并转到命令的描述。
为方便起见,从中创建一个函数并将其放入您的~/.bashrc:
function manbash {
man -P "less +/\ \ \ $1" bash
}
Run Code Online (Sandbox Code Playgroud)
并像manbash pushd.
另一种可能性是使用 bash 内置help:
$ help pushd
pushd: pushd [-n] [+N | -N | dir]
Add directories to stack.
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
directory. With no arguments, exchanges the top two directories.
Options:
[...]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1022 次 |
| 最近记录: |