マニュアルページの紹介や説明を印刷する簡単な方法

マニュアルページの紹介や説明を印刷する簡単な方法

マニュアルページの簡単な要約(説明や紹介)をすばやく表示する簡単な方法はありますか?これを行うためのオプション/フラグはありません。これを行うためのその他のツールはありますか?

答え1

これまとめまとめ言及されたOPは何ですか?名前特殊加工部品mandbまたはmakewhatis(データの準備whatisそしてapropos

通常、これはこれらのツールで1行です(実際のマンページの長さのために改行される可能性があります)。また、(まだ慣例通り)タイトル(左)と簡単な説明の間にダッシュがあります。

追加資料(Linux):

man -k 印刷機能
検索キーワードの簡単な説明とマニュアルページ名印刷機能正規表現で。一致するものをすべて印刷してください。等しいapropos printf

man -f 郵便
参照されたマニュアルページを見つけて、見つかったsmail項目の簡単な説明を印刷します。等しいwhatis smail

このaproposリストには、短い説明の行のすべての部分の一致が表示されるため、より多くの結果が得られます。たとえば、次のようにapropos printf表示できます。

asprintf (3)         - print to allocated string
dprintf (3)          - print to a file descriptor
fprintf (3)          - formatted output conversion
fwprintf (3)         - formatted wide-character output conversion
printf (1)           - format and print data
printf (3)           - formatted output conversion
snprintf (3)         - formatted output conversion
sprintf (3)          - formatted output conversion
swprintf (3)         - formatted wide-character output conversion
vasprintf (3)        - print to allocated string
vdprintf (3)         - print to a file descriptor
vfprintf (3)         - formatted output conversion
vfwprintf (3)        - formatted wide-character output conversion
vprintf (3)          - formatted output conversion
vsnprintf (3)        - formatted output conversion
vsprintf (3)         - formatted output conversion
vswprintf (3)        - formatted wide-character output conversion
vwprintf (3)         - formatted wide-character output conversion
wprintf (3)          - formatted wide-character output conversion
XtAsprintf (3)       - memory management functions

ただし、whatis特定のトピック名を持つページを見つけるには、次の手順を実行します。

printf (1)           - format and print data  
printf (3)           - formatted output conversion

他のシステムは異なる場合があります。

  • OSX マニュアルページman(1)、オプションは -k次のとおりです。apropos。順番に、apropos 説明する「aproposは、キーワードwordを含むシステムコマンドの簡単な説明を見つけるために一連のデータベースファイルを検索し、その結果を標準出力に表示します」と言います。名前その部分には、「apropos - Whatisデータベースから文字列を検索する」と記載されています。
  • OSX マニュアルページmanpages(5)マンページの構造が提供されます。

各ケースのプログラムには、manおよび対応するオプションがありますが、さまざまなUnixシリーズシステムでは別々のプログラムがより一般的に使用されます。aproposwhatis

興味深いことに、POSIXのみman(および-kオプション)、一致しませんwhatis。理由に記載されている

これ-fこのオプションは考慮されましたが、実装の違いにより、今回のPOSIX.1-2008ボリュームには含まれませんでした。

また、POSIXは用語を使用しません。まさにしかし、説明します。同様に、POSIXは(少なくともこのセクションでは)個々のマンページの構造を説明したり、セクションとして構成したりしません。これはシステム固有の機能です。

答え2

次のいくつかの機能は、バーを表示して特定のバーを抽出することで改善できると確信しています。

使用:

mansubs <コマンド>
manedit <コマンド> <セクション>

mansubs() {
 man "$1" |col -bx|awk '/^[A-Z ]+$/ {print}'
}

manedit() {
 man "$1" |col -bx|awk -v S="$2" '$0 ~ S {cap="true"; print} $0 !~ S && /^[A-Z ]+$/ {cap="false"} $0 !~ S && !/^[A-Z ]+$/ {if(cap == "true")print}'
}

たとえば、

$ mansubs grep
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
REGULAR EXPRESSIONS
ENVIRONMENT VARIABLES
EXIT STATUS
COPYRIGHT
BUGS
SEE ALSO
NOTES

$ manedit grep SYNOPSIS
SYNOPSIS
       grep [OPTIONS] PATTERN [FILE...]
       grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

答え3

「説明」の意味によって異なります。manオプションがあります:

-f, --whatis
      Equivalent to whatis.  Display a short description from the man‐
      ual page, if available.  See whatis(1) for details.

だから:

$ man -f man                                   
man (7)              - macros to format man pages
man (1)              - an interface to the on-line reference manuals
man (1p)             - display system documentation
$ whatis man 
man (7)              - macros to format man pages
man (1)              - an interface to the on-line reference manuals
man (1p)             - display system documentation

答え4

コマンドラインスイッチを入力する前に、マニュアルページの説明セクションを参照してください。

man <command> | col -b > /tmp/randomtempfile

grepその後、sedそれを使用して必要な情報を抽出できますrandomtempfile。私が知っている限り、人には要約ページを表示するオプションはありません。

関連情報