![매뉴얼 페이지의 전체 텍스트 검색 및 apropos(1)와 같은 콘솔에서 이름 및 설명 목록 가져오기](https://linux55.com/image/193472/%EB%A7%A4%EB%89%B4%EC%96%BC%20%ED%8E%98%EC%9D%B4%EC%A7%80%EC%9D%98%20%EC%A0%84%EC%B2%B4%20%ED%85%8D%EC%8A%A4%ED%8A%B8%20%EA%B2%80%EC%83%89%20%EB%B0%8F%20apropos(1)%EC%99%80%20%EA%B0%99%EC%9D%80%20%EC%BD%98%EC%86%94%EC%97%90%EC%84%9C%20%EC%9D%B4%EB%A6%84%20%EB%B0%8F%20%EC%84%A4%EB%AA%85%20%EB%AA%A9%EB%A1%9D%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0.png)
매뉴얼 페이지에서 전체 텍스트 검색을 수행하고 이와 같은 콘솔에서 관련 매뉴얼 페이지의 이름 및 설명 목록을 얻을 수 있는 방법이 있습니까 apropos(1)
?
매뉴얼 페이지 내용의 전체 텍스트 검색을 사용할 수 있습니다 man -K
. 하지만 세 가지 문제가 있습니다.
man -K
첫 번째 결과의 제목을 콘솔에 표시하지 않습니다.man -K
아래와 같이 맨페이지 제목만 표시됩니다.--Man-- next: ansible(1) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
man -K
Ctrl-D
맨페이지 내용 보기를 건너뛰어야 합니다 . 따라서yes(1)
응답을 에 전달하는 데 사용할 수 없습니다man -K
.
답변1
더 쉬운 방법이 있을 수 있지만 검색어가 포함된 파일의 경로를 인쇄하는 man -K
것과 결합할 수 있다는 것을 알았습니다. 예를 들어 Whatis 정보를 추출하는 것과 결합할 수 있습니다.-w
lexgrog
$ man -Kws1 apropos | sort -u | xargs -rd '\n' lexgrog | perl -pe's/.*?: "(.*)"/$1/'
apropos - search the manual page names and descriptions
emacs - GNU project Emacs editor
groffer - display groff files and man pages on X and tty
info - read Info documents
lexgrog - parse header information in man pages
man - an interface to the system reference manuals
manpath - determine search path for manual pages
scanimage - scan an image
whatis - display one-line manual page descriptions
xman - Manual page display program for the X Window System
(이것은 GNU가 그것 과 옵션을 xargs
대표한다고 가정하지만 , 후자가 필요하지는 않을 것입니다)-r
-d
full-apropos
다음 과 같은 스크립트나 함수 로 변환할 수 있습니다 .
#! /bin/sh -
man -Kw "$@" |
sort -u |
xargs -rd '\n' lexgrog |
perl -pe's/.*?: "(.*)"/$1/'
그러나 우리는 정보의 man 부분을 놓치고 있습니다. 파일 경로에 있으므로 다음을 사용하여 다시 추가할 수 있습니다.
#! /bin/sh -
man -Kw "$@" |
sort -u |
while IFS= read -r file; do
section=${file%/*}
section=${section##*/man}
lexgrog -- "$file" |
perl -spe's/.*?: "(.*)"/$1/; s/ - / ($s)$&/' -- "-s=$section"
done