如何在手册页中搜索`!`(感叹号)?


13

我想在中的命令中获得!选项的解释(这意味着排除)。findman find

然后我按/shift + 1Non-match弹出了,而不是。! 那么我的问题是如何!在联机帮助页中进行搜索?

图片

Answers:


17

默认的man传呼机是less。如果您查看less的帮助(h在其中按时),则会看到:

                          SEARCHING

  /pattern          *  Search forward for (N-th) matching line.
  ?pattern          *  Search backward for (N-th) matching line.
  n                 *  Repeat previous search (for N-th occurrence).
  N                 *  Repeat previous search in reverse direction.
  ESC-n             *  Repeat previous search, spanning files.
  ESC-N             *  Repeat previous search, reverse dir. & spanning files.
  ESC-u                Undo (toggle) search highlighting.
  &pattern          *  Display only matching lines
        ---------------------------------------------------
        A search pattern may be preceded by one or more of:
        ^N or !  Search for NON-matching lines.

或在man less

/pattern
      Search forward in the file for the N-th line containing the pat‐
      tern.  N defaults to 1.  The pattern is a regular expression, as
      recognized  by  the  regular expression library supplied by your
      system.  The search starts at the first line displayed (but  see
      the -a and -j options, which change this).

      Certain  characters  are  special if entered at the beginning of
      the pattern; they modify the type of search rather  than  become
      part of the pattern:

      ^N or !
             Search for lines which do NOT match the pattern.

因此,正义模式!是一个空模式(匹配任何东西),否定了 -因此没有东西会匹配它。

您必须!通过使用反斜杠(\!)或使其不成为正则表达式的第一个字符(/[!]例如)来逃避模式开头的重要性。

另一种方法是使用grep

$ man find | grep !
       with  `-', or the argument `(' or `!'.  That argument and any following
       ! expr True  if  expr  is false.  This character will also usually need
              Same as ! expr, but not POSIX compliant.
       The POSIX standard specifies parentheses `(', `)', negation `!' and the
       find /sbin /usr/sbin -executable \! -readable -print
       find . -perm -444 -perm /222 ! -perm /111
       find . -perm -a+r -perm /a+w ! -perm /a+x
       -perm  /222 or -perm /a+w) but are not executable for anybody ( ! -perm
       /111 and ! -perm /a+x respectively).
       find . -name .snapshot -prune -o \( \! -name *~ -print0 \)|

9

您需要先键入,\然后再键入!,这样它才不会在搜索中解释为否定正则表达式。


4

另一种方法是:

man --html=firefox find

在firefox中打开联机帮助页后,按CTRL+ F搜索任何字符。


4
那是--html-H
蜘蛛鲍里斯(Boris)
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.