
ファイル内の内容をパラメータとして指定してファイルを検索する方法を知りたいです。そのソリューションを適用して、Richard Stallman が提供したコマンド (man ページ経由) を検索することができます。
答え1
からman man
:
-K, --global-apropos
Search for text in all manual pages. This is a brute-force
search, and is likely to take some time; if you can, you should
specify a section to reduce the number of pages that need to be
searched. Search terms may be simple strings (the default), or
regular expressions if the --regex option is used.
-w, --where, --location
Don't actually display the manual pages, but do print the
location(s) of the source nroff files that would be formatted.
組み合わせ:
man -wK 'Richard M Stllman'
ただし、man ページには のみが含まれておりRichard Stallman
、2 つの単語間のスペースの量は可変であるため、正規表現が適切である可能性があります。
--regex
Show all pages with any part of either their names or their
descriptions matching each page argument as a regular
expression, as with apropos(1). Since there is usually no
reasonable way to pick a "best" page when searching for a
regular expression, this option implies -a.
それで:
man --regex -wK 'Richard *Stallman'
答え2
このコマンドは、キーワードを含む man ファイルのファイル名を表示しますStallman
。
zgrep -l Stallman /usr/share/man/man?/*
15.10 の出力は次のように始まります:
/usr/share/man/man1/cat.1.gz
/usr/share/man/man1/comm.1.gz
/usr/share/man/man1/ctags.1.gz
/usr/share/man/man1/ctags.emacs24.1.gz
その後は、、などを使用してman cat
通常どおり閲覧できます。man comm
答え3
この方法では、キーワードでマニュアルページ全体を検索するのではなく、各マニュアルページのタイトルと短い説明のみを検索します。これは十分ではありませんが、何かをすばやく調べるのに役立ちます。目的の結果が返されない場合は、@を使用する必要があります。哲学の答え。
あなたはapropos
インストールされているすべてのマニュアルページのタイトルと説明をキーワードで素早く検索するコマンド:
$ apropos chat
chat (8) - Automated conversational script with a modem
chattr (1) - change file attributes on a Linux file system
empathy (1) - GNOME multi-protocol chat and call client
既知のマニュアルページの説明を表示するには、以下を使用しますwhatis
。
$ whatis empathy
empathy (1) - GNOME multi-protocol chat and call client
前述したように、このメソッドは manpage 本体全体を検索しないため、apropos Stallman
何も返しません...