2016/05/16

man page 를 stdout 으로 표시하거나 파일로 저장하는 방법

Revision History
2016/05/16 18:03:44 - 최초 작성

Tested: OS X El Capitan Version 10.11.4

맨 페이지의 정보는 -P 옵션으로 cat 명령을 호출하여 쉽게 표준 출력으로 내보낼 수 있습니다.

man 명령의 도움말
$ man -h
man, version 1.6c

usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list]
 [-m system] [-p string] name ...

  a : find all matching entries
  c : do not use cat file
  d : print gobs of debugging information
  D : as for -d, but also display the pages
  f : same as whatis(1)
  h : print this help message
  k : same as apropos(1)
  K : search for a string in all pages
  t : use troff to format pages for printing
  w : print location of man page(s) that would be displayed
      (if no name given: print directories that would be searched)
  W : as for -w, but display filenames only

  C file   : use `file' as configuration file
  M path   : set search path for manual pages to `path'
  P pager  : use program `pager' to display pages
  S list   : colon separated section list
  m system : search for alternate system's man pages
  p string : string tells which preprocessors to run
               e - [n]eqn(1)   p - pic(1)    t - tbl(1)
               g - grap(1)     r - refer(1)  v - vgrind(1)

기본 설정은 터미널 창의 넓이에 맞게 출력됩니다.
$ man -P cat chmod

CHMOD(1)                  BSD General Commands Manual                 CHMOD(1)

NAME
     chmod -- change file modes or Access Control Lists

SYNOPSIS
     chmod [-fv] [-R [-H | -L | -P]] mode file ...
     chmod [-fv] [-R [-H | -L | -P]] [-a | +a | =a] ACE file ...
     chmod [-fhv] [-R [-H | -L | -P]] [-E] file ...
     chmod [-fhv] [-R [-H | -L | -P]] [-C] file ...
     chmod [-fhv] [-R [-H | -L | -P]] [-N] file ...

DESCRIPTION
     The chmod utility modifies the file mode bits of the listed files as specified by the mode operand. It
     may also be used to modify the Access Control Lists (ACLs) associated with the listed files.

따라서 직접 넓이를 지정해서 80 컬럼으로 출력하려면 환경변수를 설정해주어야 합니다.
$ MANWIDTH=80 man -P cat chmod

CHMOD(1)                  BSD General Commands Manual                 CHMOD(1)

NAME
     chmod -- change file modes or Access Control Lists

SYNOPSIS
     chmod [-fv] [-R [-H | -L | -P]] mode file ...
     chmod [-fv] [-R [-H | -L | -P]] [-a | +a | =a] ACE file ...
     chmod [-fhv] [-R [-H | -L | -P]] [-E] file ...
     chmod [-fhv] [-R [-H | -L | -P]] [-C] file ...
     chmod [-fhv] [-R [-H | -L | -P]] [-N] file ...

DESCRIPTION
     The chmod utility modifies the file mode bits of the listed files as
     specified by the mode operand. It may also be used to modify the Access
     Control Lists (ACLs) associated with the listed files.


검색: Man Page, 맨 페이지, 도움말, Stdout, 표준 출력, 

댓글 없음:

댓글 쓰기