
파일 내의 내용을 매개변수로 제공하여 파일을 검색하는 방법을 배우고 싶습니다. 그런 다음 솔루션을 적용하여 Richard Stallman이 제공한 명령을 검색할 수 있습니다(맨 페이지를 통해).
답변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'
맨페이지에는 일반적으로 Richard Stallman
두 단어 사이에 다양한 공백이 있는 가 있으므로 정규 표현식이 적절할 수 있습니다.
--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
내가 말했듯이, 이 방법은 전체 맨페이지 본문을 검색하지 않으므로 apropos Stallman
아무것도 반환하지 않습니다.