Como posso imprimir uma seção de um manual (man)?

1

Do terminal, como posso imprimir para produzir uma seção específica do resultado de man something ?

Por exemplo, se eu quisesse obter algumas informações sobre o valor de retorno da função C, eu gostaria de ver algo assim:

RETURN VALUE
       On  success,  the  number  of bytes written is returned (zero indicates
       nothing was written).  It is not an error if  this  number  is  smaller
       than the number of bytes requested; this may happen for example because
       the disk device was filled.  See also NOTES.

       On error, -1 is returned, and errno is set appropriately.

       If count is zero and fd refers to a  regular  file,  then  write()  may
       return  a failure status if one of the errors below is detected.  If no
       errors are detected, or error detection is not  performed,  0  will  be
       returned  without  causing  any  other effect.  If count is zero and fd
       refers to a file other than a regular file, the results are not  speci‐
       fied.

ERRORS
       EAGAIN The  file descriptor fd refers to a file other than a socket and
          has been marked nonblocking (O_NONBLOCK), and  the  write  would
          block.  See open(2) for further details on the O_NONBLOCK flag.

       EAGAIN or EWOULDBLOCK
          The  file  descriptor  fd refers to a socket and has been marked
          nonblocking   (O_NONBLOCK),   and   the   write   would   block.
[...]

em vez de:

WRITE(2)                   Linux Programmer's Manual                  WRITE(2)

NAME
       write - write to a file descriptor

SYNOPSIS
       #include <unistd.h>

       ssize_t write(int fd, const void *buf, size_t count);

DESCRIPTION
       write()  writes  up  to  count bytes from the buffer pointed buf to the
       file referred to by the file descriptor fd.

       The number of bytes written may be less than  count  if,  for  example,
       there  is  insufficient space on the underlying physical medium, or the
       RLIMIT_FSIZE resource limit is encountered (see setrlimit(2)),  or  the
       call was interrupted by a signal handler after having written less than
       count bytes.  (See also pipe(7).)

       For a seekable file (i.e., one to which lseek(2) may  be  applied,  for
       example,  a  regular file) writing takes place at the current file off‐
       set, and the file offset is incremented by the number of bytes actually

[...]
    
por untitled 16.05.2016 / 21:32

3 respostas

2

Para citar meu próprio post do Meta :

Vinculando a páginas de manual

Já tenho um método favorito para isso, sobre o qual você pode ler na página less man em dois lugares:

LESS='+/\+cmd' man less

e

LESS='+/LESS[[:space:]]*Options' man less

(Veja o que eu fiz lá?)

    
por 16.05.2016 / 22:06
2

Você pode usar o sinal -P do programa man para usar um pager para exibir páginas. Por exemplo, você pode usar less como o programa pager com o sinalizador -p para procurar o padrão ERROR que acontece no início da linha dentro da página man:

man -P 'less -p ^ERRORS' symlink

Isso abre a página de manual de symlink e pula diretamente para a seção ERRORS dele.

    
por 16.05.2016 / 22:19
0

Se você acabou de abrir uma página de manual como:
man cowsay
Você pode então digitar:
/AUTHOR
para encontrar e pular para a linha AUTHOR, por exemplo. Ou: /myFunction
encontrar instâncias de myFunction na manpage.
(Se houver várias instâncias, você pode pressionar n para ir para a próxima instância)

Além disso, se você estiver em uma página man, você pode digitar h e obter um resumo de menos comandos, como abaixo. Eu os cortei depois de partes que achei que eram relevantes para você, mas tem mais.

                  SUMMARY OF LESS COMMANDS

      Commands marked with * may be preceded by a number, N.
      Notes in parentheses indicate the behavior if N is given.

  h  H                 Display this help.
  q  :q  Q  :Q  ZZ     Exit.
 ---------------------------------------------------------------------------

                           MOVING

  e  ^E  j  ^N  CR  *  Forward  one line   (or N lines).
  y  ^Y  k  ^K  ^P  *  Backward one line   (or N lines).
  f  ^F  ^V  SPACE  *  Forward  one window (or N lines).
  b  ^B  ESC-v      *  Backward one window (or N lines).
  z                 *  Forward  one window (and set window to N).
  w                 *  Backward one window (and set window to N).
  ESC-SPACE         *  Forward  one window, but don't stop at end-of-file.
  d  ^D             *  Forward  one half-window (and set half-window to N).
  u  ^U             *  Backward one half-window (and set half-window to N).
  ESC-)  RightArrow *  Left  one half screen width (or N positions).
  ESC-(  LeftArrow  *  Right one half screen width (or N positions).
  F                    Forward forever; like "tail -f".
  r  ^R  ^L            Repaint screen.
  R                    Repaint screen, discarding buffered input.
        ---------------------------------------------------
        Default "window" is the screen height.
        Default "half-window" is half of the screen height.
 ---------------------------------------------------------------------------

                          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
        ---------------------------------------------------
        Search patterns may be modified by one or more of:
        ^N or !  Search for NON-matching lines.
        ^E or *  Search multiple files (pass thru END OF FILE).
        ^F or @  Start search at FIRST file (for /) or last file (for ?).
        ^K       Highlight matches, but don't move (KEEP position).
        ^R       Don't use REGULAR EXPRESSIONS.
 ---------------------------------------------------------------------------

                           JUMPING

  g    ESC->       *  Go to last line in file (or line N).
  p  %              *  Go to beginning of file (or N percent into file).

Se você quiser ler mais facilmente as páginas do manual, isso deve funcionar.

    
por 16.05.2016 / 21:59