マニュアルページでテキスト(特定のオプションなど)を見つけるには、コマンドラインからgrepするのが便利だと思います。
ただし、以下のようにパターンのみが一致し、パターンは何も一致しないgrep
マニュアルページで作業していると期待どおりに機能しません()。"-f"
"-"
"--file"
alias grep='grep --color=always'
nlykkei-mbp:~ nlykkei$ alias grep
alias grep='grep --color=always'
nlykkei-mbp:~ nlykkei$ man grep | grep -e "-f"
[-e pattern] [-f file] [--binary-files=value] [--color[=when]]
-F, --fixed-strings
-f file, --file=file
-h, --no-filename
--binary-file=without-match option.
-L, --files-without-match
-l, --files-with-matches
--binary-files=value
and the behaviour of the -f flag when used with an empty pattern file is
nlykkei-mbp:~ nlykkei$ man grep | grep -e "--file"
nlykkei-mbp:~ nlykkei$ echo "--file" | grep -e "--file"
--file
nlykkei-mbp:~ nlykkei$ ▒
代わりに、一致するパイプテキストがecho
期待どおりに機能しますが、これはマニュアルページの「見えない」形式に関連していますか?マニュアルページのgrepテキストを信頼できますか?
注:私はとman -k
について知っていますが、man -K
これらは私が達成したいことを完全に解決しません。
ベストアンサー1
解決策1:man用の特定のconfファイルの使用
構成ファイル.man.raw.conf
NROFF /usr/bin/groff -mandoc -Tlatin1 -P-u -P-b
使用例man
MyMAC:tmp e444$$ man -C .man.raw.conf grep | grep -e --file
-f file, --file=file
-L, --files-without-match
-l, --files-with-matches
解決策2:使用colcrt -
MyMAC:tmp e444$ man grep | colcrt - | grep -e --file
-f file, --file=file
-L, --files-without-match
-l, --files-with-matches
ps 1:-
より多くのゴミを追加するcolcrtなし
ps 2:この質問と回答はLinuxでは動作が異なるため意味がありません。