打开手册页并在单个命令中搜索字符串


Answers:


20

试试这个技巧:

man chmod | less +'/a\+x'

要么

man chmod | more +'/a\+x'

在符号前加上反斜杠,+因为其后/扩展的正则表达式


2
很酷的把戏,我不知道那一个!
terdon

但现在,您确实=)
Gilles Quenot

5
-p开关避免了需要相当难看+/...
jasonwryan

2
@JosephR,不,只是less(和大多数寻呼机)的行为就像cat输出不是终端一样。
斯特凡Chazelas

1
如果less已经是您的手册页,您也可以通过运行进行优化LESS=+/searched_string man foobar。这也有工作的优势man -a
斯特凡Chazelas

0

据我所知(但@sputnick 指出,我并不了解),但是您可以解析它:

man chmod | grep -C 5 'a+x'

我建议使用手册页中实际存在的字符串,例如:

$ man chmod | grep -C 5 set-user-ID
   traversals.

SETUID AND SETGID BITS
   chmod  clears  the  set-group-ID  bit  of a regular file if the file's group ID does not match the
   user's effective group ID or one of the user's supplementary group IDs, unless the user has appro‐
   priate  privileges.   Additional  restrictions  may cause the set-user-ID and set-group-ID bits of
   MODE or RFILE to be ignored.  This behavior depends on the policy and functionality of the  under‐
   lying chmod system call.  When in doubt, check the underlying system behavior.

   chmod preserves a directory's set-user-ID and set-group-ID bits unless you explicitly specify oth‐
   erwise.  You can set or clear the bits with symbolic modes like u+s and g-s, and you can set  (but
   not clear) the bits with a numeric mode.

RESTRICTED DELETION FLAG OR STICKY BIT
   The  restricted  deletion  flag or sticky bit is a single bit, whose interpretation depends on the

是的,如果该页面中甚至还有a + x,我可能应该先进行测试:)这是我想到的第一件事。
2013年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.