您的位置:首页 > 其它

如何快速掌握man手册的使用

2017-10-20 07:46 741 查看
man手册内容详细,解释到位,因为好多都是软件的原创者自己写的说明文档,当然是第一手的资料。但是,有几个难点需要克服:

1、英文不易阅读,通常我是先在书上或者网络上找到某个命令的详细说明和解释,然后在通过man手册查看该命令,通俗的讲:带着答案看问题的方法。勉强能够读懂,下一次再次忘记了该命令的用法,直接看man手册(毕竟方便嘛),如果又看不懂了,在查书和网络,把看不懂的地方反复强化,几次后基本就能明白man的英文语义了。

2、不会使用man。其实只有几个常用的命令:

man -f 命令名 //用一句话描述该命令的用途,等同于”whatis“命令,例如:

fly@noi:~$ man grep
fly@noi:~$ man -f grep
grep (1)             - print lines matching a pattern
fly@noi:~$ whatis grep
grep (1)             - print lines matching a pattern
fly@noi:~$


man -k 命令名 //显示所有包含该命令名的所有命令

fly@noi:~$ man -k grep
bzegrep (1)          - search possibly bzip2 compressed files for a regular expression
bzfgrep (1)          - search possibly bzip2 compressed files for a regular expression
bzgrep (1)           - search possibly bzip2 compressed files for a regular expression
egrep (1)            - print lines matching a pattern
fgrep (1)            - print lines matching a pattern
git-grep (1)         - Print lines matching a pattern
grep (1)             - print lines matching a pattern
grepdiff (1)         - show files modified by a diff containing a regex
lzegrep (1)          - search compressed files for a regular expression
lzfgrep (1)          - search compressed files for a regular expression
lzgrep (1)           - search compressed files for a regular expression
msggrep (1)          - pattern matching on message catalog
pgrep (1)            - look up or signal processes based on name and other attributes
ptargrep (1)         - Apply pattern matching to the contents of files in a tar archive
rgrep (1)            - print lines matching a pattern
xzegrep (1)          - search compressed files for a regular expression
xzfgrep (1)          - search compressed files for a regular expression
xzgrep (1)           - search compressed files for a regular expression
zegrep (1)           - search possibly compressed files for a regular expression
zfgrep (1)           - search possibly compressed files for a regular expression
zgrep (1)            - search possibly compressed files for a regular expression
zipgrep (1)          - search files in a ZIP archive for lines matching a pattern
fly@noi:~$


3、搜索指定章节的关键字,下面的echo在第1和8章都有,如果我想找第1章的:

fly@noi:~$ man -k echo
echo (1)             - display a line of text
l2ping (1)           - Send L2CAP echo request and receive answer
lessecho (1)         - expand metacharacters
pam_echo (8)         - PAM module for printing text messages
ping (8)             - send ICMP ECHO_REQUEST to network hosts
ping6 (8)            - send ICMP ECHO_REQUEST to network hosts
xmessage (1)         - display a message or query in a window (X-based /bin/echo)
fly@noi:~$ man -s 1 -k echo
echo (1)             - display a line of text
l2ping (1)           - Send L2CAP echo request and receive answer
lessecho (1)         - expand metacharacters
xmessage (1)         - display a message or query in a window (X-based /bin/echo)
fly@noi:~$


4、如果同一个命令,几个章都有,可以指定章号来显示:

fly@noi:~$ man -f printf
printf (1)           - format and print data
printf (3)           - formatted output conversion
fly@noi:~$ man 3 printf    //这样就可以显示第3章的了,否则默认是第1章


5、在man手册页内,也查找指定参数:

比如:我想找grep的--color参数的用法:

/--color   //注意:如果有很多选项可以在单词后面加空格在搜索


我想找grep命令中某一个单词,用"\< \>"命令,可以准确匹配一个词,词只能由字母、数字、下划线组成。

/\<n\>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: