Find word in man page

Is there a option to search within manpages?

8128's user avatar

8128

28.5k27 gold badges109 silver badges145 bronze badges

asked Jan 9, 2011 at 16:01

NES's user avatar

4

Just hit /, and type your search pattern.

  • Patterns can be regular expressions, for example, you could search for the word «option» by typing:

    /[Oo]ption
    

    Or find all of the long arguments with:

    /(--)[a-Z]
    

    To cancel the search, hit Ctrl+C.

    Some useful quantification operators are:

      ?    for zero or one of the preceding expression
      *    for zero or more of the preceding expression
      +    for one or more of the preceding expression
    

    And expressions can be «grouped» with parentheses, as in (--)+ (for two or more dashes).

    [a-Z] is a sequence (others include [0-9], [a-z], and so on). Sequences can be combined, as in [a-Z0-9]. You can also invert expressions with the ^ operator, e.g. (--)[^a-Z]+ for all long arguments that start with anything other than a letter.

    Another useful operation is Union (|), as in color|colour, which finds every occurrence of either «color» or «colour» (this is sometimes called boolean OR).

    If you are searching for strings containing some of these «reserved» characters (like ?, *, +), prefix them with a (i.e. /+k to search for +k).

  • To jump through the results, press N (forwards) and Shift+N (backwards).

  • There is also a way to search across all manpages:

    man -K "Hello World"
    

    The man program will open the first match, and after you close it with q, offer you to

    • view the current one (Return)
    • skip the current one (Ctrl+D)
    • or exit (Ctrl+C)

BeastOfCaerbannog's user avatar

answered Jan 9, 2011 at 16:08

Stefano Palazzo's user avatar

Stefano PalazzoStefano Palazzo

85.1k45 gold badges208 silver badges227 bronze badges

11

Minor appendix to the excellent answer from Stefano:

man uses less when no other pager specified. So you can search either with / or with ?.

If you search with / then you search forward and you use n to find the next match and N to find previous match and if you search with ? (search backward) n will search previous match and N will search the next match.

Use man less for the details.

Also you may use man -wK word to list out all manual files with some word.

answered Sep 4, 2018 at 10:44

prosti's user avatar

prostiprosti

9699 silver badges14 bronze badges

If you are already in the man page, / search is easy to use, but I prefer to specify my search word with the man command, so it opens directly on the first occurrence of the term.

This is fairly straight forward with a pipe:

man ksh | less +/LINENO

But if you wanted to stick only to man options, it seems to be very roundabout. You have to override the default output pager (less -f) with the -P option.

man -P 'less -p LINENO' ksh

answered Jul 3, 2019 at 20:51

Amit Naidu's user avatar

Amit NaiduAmit Naidu

1831 silver badge4 bronze badges

1

GUI Methods

If you have Ubuntu Desktop version installed you can search graphically.

Gnome Help

Gnome help uses yelp program. Instead of typing man ls for the CLI man page you can type yelp man:ls and view in GUI window:

yelp man:ls.png

Once loaded you can use Control + F to search.

Browser

I open the man page on the internet and use my browsers search feature Control + F.

For example if in the terminal I type in man yad in my browser I would type linux man yad.

You sometimes need to pay attention that the internet version can sometimes have newer or older list of arguments but this has rarely happened to me.

The advantages of internet manpages goes beyond search facility and includes superior scrolling plus easier copying to clipboard.

answered Jul 3, 2019 at 22:03

WinEunuuchs2Unix's user avatar

WinEunuuchs2UnixWinEunuuchs2Unix

98k33 gold badges232 silver badges401 bronze badges

When looking for a certain word or phrase in the man page of Linux command, one can type ‘/’ followed by the word or phrase to search for it.

What I’d like to be able to do is to search for the next occurrence of the word or phrase without having to type it out again. Kinda like when you use ctrl+f in a browser to search for a word, and then press enter to find the next occurrence of that word.

If this is possible to do, how do I do it?

Hastur's user avatar

Hastur

18.5k8 gold badges51 silver badges94 bronze badges

asked Jun 29, 2011 at 18:05

Eddy's user avatar

Use n and ShiftN for the next and previous matches.

(The default pager used for manual pages is less, which has similar shortcuts to those in the vim text editor.)

answered Jun 29, 2011 at 18:15

user1686's user avatar

user1686user1686

409k61 gold badges860 silver badges930 bronze badges

1

Type / followed by Enter; an empty regex always means the previous successfully matched regex.

answered Jun 29, 2011 at 18:06

geekosaur's user avatar

geekosaurgeekosaur

11.6k32 silver badges39 bronze badges

1

Sometimes I need to look up certain words through all the manual pages. I am aware of apropos, but if I understand its manual right, it restricts search to the descriptions only.

Each manual page has a short description available within it. apropos searches the descriptions for instances of keyword.

For example, if I look up a word like ‘viminfo’, I get no results at all…

$ apropos viminfo
viminfo: nothing appropriate.

… although this word exists in a later section of the manual of Vim (which is installed on my system).

   -i {viminfo}
               When  using  the  viminfo file is enabled, this option sets the filename to use, instead of the default "~/.vim‐
               info".  This can also be used to skip the use of the .viminfo file, by giving the name "NONE".

So how can I look up a word through every section of every manual?

Gilles 'SO- stop being evil''s user avatar

asked Apr 11, 2015 at 2:35

Helmyano's user avatar

From 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.

This directly opens the manpage (vim, then ex, then gview, …) for me, so you could add another option, like -w to get an idea of which manpage will be displayed.

$ man -wK viminfo
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/run-one.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/run-one.1.gz
/usr/share/man/man1/run-one.1.gz
...

answered Apr 11, 2015 at 3:37

muru's user avatar

murumuru

68k12 gold badges190 silver badges286 bronze badges

2

Use the global apropos option in 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.

So, man -K viminfo will give you the page you need.

answered Apr 11, 2015 at 3:38

cremefraiche's user avatar

NetBSD has a full text search implementation of apropos(1) which does search across the complete content of man pages instead of restricting just to the NAME section. You might want to check it out.

There is a web based interface for it as well: man-k.org


Disclaimer: I am the developer of both of the tools.

answered Apr 19, 2016 at 19:16

Abhinav Upadhyay's user avatar

$ man -K "fopen"

gives you the output

/usr/share/man/en/man3/fclose.3.gz? [ynq]  

y to open/display man page

n to continue search

q to Quit search

muru's user avatar

muru

68k12 gold badges190 silver badges286 bronze badges

answered Apr 11, 2015 at 6:46

Chittaranjan Mohanta's user avatar

When viewing a manpage say man ls, how does one search the content of the man page? (similarly, in vim you can call :/search_string what is a comprable command while viewing a man page?)

asked Feb 15, 2012 at 20:46

rudolph9's user avatar

2

It depends on which pager you use, which depends on your MANPAGER/PAGER environment variable. The manpage of man says:

If MANPAGER is set, its value is used as the name of the program to use to display the man page. If not, then PAGER is used. If that has no value either, /usr/bin/less -is is used.

Note that on Debian unstable the default is pager -s (managed by alternatives).
So, if you actually are using less, just type /searchstring, similar to vim.
See also the manpage of less on how to navigate in less.

answered Feb 15, 2012 at 20:51

Alex P.'s user avatar

Alex P.Alex P.

7606 silver badges6 bronze badges

On Ubuntu (and probably similar distributions), you type "/" followed by what you want to search for

Example:

/word

Pressing "n" jumps to the next hit

answered Feb 15, 2012 at 20:50

Optimist's user avatar

OptimistOptimist

3871 silver badge5 bronze badges

Search man pages

Command line users are undoubtedly familiar with man pages, or manual pages, that contain details, help, and documentation to specified commands and functions. Referencing a man page can be essential when trying to learn proper syntax or how a command works, but with how large some manual pages are it can be a real drag to scroll through the entire man page to try and find a relevant portion. Additionally sometimes you just don’t know exactly which manual page you should look for relevant data for. Fortunately there are two search tools to search man pages and quickly find and access exactly what you’re looking for, whether finding and matching a string or search term in a currently active man page or by searching all manual pages for a match.

Searching man pages works the same in just about any unix based command line, whether it’s Mac OS, Linux, BSD, or whatever else. Here’s how it works:

How to Search All Man Pages for a String Match

If you want to find something about a general command, function, or feature, but you aren’t certain which man page the data will be in, or perhaps you just want to find all references to something, you an use a broad string match to search every single manual page on the computer for all matches:

man -K "String"

Note the flag is a capital -K, the string can be anything. For example, to find all manual pages that contain the string “eraseDisk” you’d use the syntax:

man -K "eraseDisk"
/usr/share/man/man3/Common Crypto.3cc? [ynq] n
/usr/share/man/man8/diskutil.8? [ynq] y

Hitting return will immediately start searching all manual pages found in /usr/share/man/* and when a match is found reports back, offering the matching manual page to you which you can accept with ‘y’ or dismiss with ‘n’ (or quit with ‘q’)

If you’re a Terminal.app user on the Mac, you’ll find the -K flag is similar to using the right-click search Man Index trick we discussed here, except it’s done entirely from the command line and requires no mouse or cursor interaction.

Search in Current Manual Page for Matches

Once you’re in a manual page, you may want to search within the currently open man page for a string match as well. That’s done with / like so:

/ search term

Let’s say we’re in the man page for launchd and you want to find matches for “LaunchAgents” within that manual page. Once you’re in man for launchd (man launchd) you’d use the following:

/launchagents

Any matches to the syntax in the current man page will be highlighted. You can then navigate between matches with n and shift+n.

Search man page for string match

The three tricks to remember to search once you’re within a man page are:

  • / search string – find matches to “search string” in current man page”
  • n – go to next match
  • shift + n – go to prior match

Remember these tips the next time you’re sorting through manual pages at the command line. And for those who use Terminal app, remember you can also search and launch manual pages from the Terminal Help menu directly, which would then allow you to use the aforementioned string search to look within a help doc to get further details.

Know of some other manual page search tricks? Let us know in the comments.

������������� ������� ��������� ��������� ���������� (man-��)

find (1)


  • >> find (1) ( Solaris man: ������� � ���������� ��������� ����������������� ������ )
  • find (1) ( FreeBSD man: ������� � ���������� ��������� ����������������� ������ )
  • find (1) ( Linux man: ������� � ���������� ��������� ����������������� ������ )
  • find (1) ( POSIX man: ������� � ���������� ��������� ����������������� ������ )
  • find (3) ( Solaris man: ������������ ������ )
  • ���� find ��������� � ���� �������� ����.
  •  

    NAME

    find - find files
     
    

    SYNOPSIS

    /usr/bin/find [-H | -L] path... expression
    
    /usr/xpg4/bin/find [-H | -L] path... expression
    

    DESCRIPTION

    The find utility recursively descends the directory hierarchy for each path seeking files that match a Boolean expression written in the primaries specified below.

    find is able to descend to arbitrary depths in a file hierarchy and does not fail due to path length limitations (unless a path operand specified by the application exceeds PATH_MAX requirements).

    find detects infinite loops; that is, entering a previously visited directory that is an ancestor of the last file encountered.
     

    OPTIONS

    The following options are supported:

    -H

    Causes the file information and file type evaluated for each symbolic link encountered on the command line to be those of the file referenced by the link, and not the link itself. If the referenced file does not exist, the file information and type is for the link itself. File
    information for all symbolic links not on the command line is that of the link itself.

    -L

    Causes the file information and file type evaluated for each symbolic link to be those of the file referenced by the link, and not the link itself. See NOTES.

    Specifying more than one of the mutually-exclusive options -H and -Lis not considered an error. The last option specified determines the behavior of the utility.
     

    OPERANDS

    The following operands are supported:

    path

    A pathname of a starting point in the directory hierarchy.

    expression

    The first argument that starts with a , or is a ! or a (, and all subsequent arguments are interpreted as an expression made up of the following primaries and operators. In the descriptions,
    wherever n is used as a primary argument, it is interpreted as a decimal integer optionally preceded by a plus (+) or minus () sign, as follows:

    +n

    more than n

    n

    exactly n

    n

    less than n

    Expressions

    Valid expressions are:

    -acl

    True if the file have additional ACLs defined.

    -amin n

    File was last accessed n minutes ago.

    -atime n

    True if the file was accessed n days ago. The access time of directories in path is changed by find itself.

    -cmin n

    File’s status was last changed n minutes ago.

    -cpio device

    Always true. Writes the current file on device in cpio format (5120-byte records).

    -ctime n

    True if the file’s status was changed n days ago.

    -depth

    Always true. Causes descent of the directory hierarchy to be done so that all entries in a directory are acted on before the directory itself. This can be useful when find is used with cpio(1) to transfer files that are contained in directories without write permission.

    -exec command

    True if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon (;). A command argument {} is replaced by the current pathname. If the last argument to -exec is {} and you specify + rather than the semicolon (;), the command is invoked fewer times, with {} replaced by groups of pathnames. If any invocation of the command returns a non-zero value as exit status, find returns a non-zero
    exit status.

    -follow

    Always true and always evaluated no matter where it appears in expression. The behavior is unspecified if -follow is used when the find command is invoked with either the -H or the -L option.
    Causes symbolic links to be followed. When following symbolic links, find keeps track of the directories visited so that it can detect infinite loops. For example, such a loop would occur if a symbolic link pointed to an ancestor. This expression should not be used with the
    find-type l expression. See NOTES.

    -fstype type

    True if the filesystem to which the file belongs is of type type.

    -group gname

    True if the file belongs to the group gname. If gname is numeric and does not appear in the /etc/group file, or in the NIS/NIS+ tables, it is taken as a group ID.

    -inum n

    True if the file has inode number n.

    -links n

    True if the file has n links.

    -local

    True if the file system type is not a remote file system type as defined in the /etc/dfs/fstypes file. nfs is used as the default remote filesystem type if the /etc/dfs/fstypes file is not present. The -local option
    descends the hierarchy of non-local directories. See EXAMPLES for an example of how to search for local files without descending.

    -ls

    Always true. Prints current pathname together with its associated statistics. These include (respectively):

    o
    inode number
    o
    size in kilobytes (1024 bytes)
    o
    protection mode
    o
    number of hard links
    o
    user
    o
    group
    o
    size in bytes
    o
    modification time.

    If the file is a special file, the size field instead contains the major and minor device numbers.

    If the file is a symbolic link, the pathname of the linked-to file is printed preceded by `->‘. The format is identical to that of ls -gilds (see ls(1B)).

    Formatting is done internally, without executing the ls program.

    -mmin n

    File’s data was last modified n minutes ago.

    -mount

    Always true. Restricts the search to the file system containing the directory specified. Does not list mount points to other file systems.

    -mtime n

    True if the file’s data was modified n days ago.

    -name pattern

    True if pattern matches the basename of the current file name. Normal shell file name generation characters (see sh(1))
    can be used. A backslash () is used as an escape character within the pattern. The pattern should be escaped or quoted when find is invoked from the shell.

    Unless the character ‘.‘ is explicitly specified in the beginning of pattern, a current file name beginning with ‘.‘ does not match pattern when using /usr/bin/find. /usr/xpg4/bin/find does not make this distinction; wildcard file name generation characters can match file names beginning with ‘.‘.

    -ncpio device

    Always true. Writes the current file on device in cpio -c format (5120 byte records).

    -newer file

    True if the current file has been modified more recently than the argument file.

    -nogroup

    True if the file belongs to a group not in the /etc/group file, or in the NIS/NIS+ tables.

    -nouser

    True if the file belongs to a user not in the /etc/passwd file, or in the NIS/NIS+ tables.

    -ok command

    Like -exec, except that the generated command line is printed with a question mark first, and is executed only if the response is affirmative.

    -perm []mode

    The mode argument is used to represent file mode bits. It is identical in format to the symbolic mode operand, symbolic_mode_list, described in chmod(1), and is interpreted as follows. To start, a template is assumed with all file mode bits cleared. An op symbol of:

    +

    Set the appropriate mode bits in the template

    Clear the appropriate bits

    =

    Set the appropriate mode bits, without regard to the contents of the file mode creation mask of the process

    The op symbol of cannot be the first character of mode, to avoid ambiguity with the optional leading hyphen. Since the initial mode is all bits off, there are no symbolic modes that need to use as
    the first character.

    If the hyphen is omitted, the primary evaluates as true when the file permission bits exactly match the value of the resulting template.

    Otherwise, if mode is prefixed by a hyphen, the primary evaluates as true if at least all the bits in the resulting template are set in the file permission bits.

    -perm []onum

    True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is
    prefixed by a minus sign (), only the bits that are set in onum are compared with the file permission flags, and the expression evaluates true if they match.

    -print

    Always true. Causes the current pathname to be printed.

    -prune

    Always yields true. Does not examine any directories or files in the directory structure below the pattern just matched. (See EXAMPLES). If -depth is specified, -prune has no effect.

    -size n[c]

    True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in bytes.

    -type c

    True if the type of the file is c, where c is b, c, d, D, f, l, p, or s for
    block special file, character special file, directory, door, plain file, symbolic link, fifo (named pipe), or socket, respectively.

    -user uname

    True if the file belongs to the user uname. If uname is numeric and does not appear as a login name in the /etc/passwd file, or in the NIS/NIS+ tables, it is taken as
    a user ID.

    -xdev

    Same as the -mount primary.

    -xattr

    True if the file has extended attributes.

    Complex Expressions

    The primaries can be combined using the following operators (in order of decreasing precedence):

    1)(expression)

    True if the parenthesized expression is true (parentheses are special to the shell and must be escaped).

    2)!expression

    The negation of a primary (! is the unary not operator).

    3) expression[-a] expression

    Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries).

    4) expression-oexpression

    Alternation of primaries (-o is the or operator).

    When you use find in conjunction with cpio, if you use the -L option with cpio, you must use the -L option or the -follow primitive with find and vice versa. Otherwise
    the results are unspecified.

    If no expression is present, -print is used as the expression. Otherwise, if the specified expression does not contain any of the primaries -exec, -ok, -ls, or -print, the specified
    expression is effectively replaced by:

    (specified) -print

    The -user, -group, and -newer primaries each evaluate their respective arguments only once. Invocation of command specified by -exec or -ok does not affect subsequent primaries on the
    same file.
     

    USAGE

    See largefile(5) for the description of the behavior of find when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
     

    EXAMPLES

    Example 1 Writing Out the Hierarchy Directory

    The following commands are equivalent:

    example% find .
    example% find . -print
    

    They both write out the entire directory hierarchy from the current directory.

    Example 2 Removing Files

    The following comand removes all files in your home directory named a.out or *.o that have not been accessed for a week:

    example% find $HOME ( -name a.out -o -name '*.o' ) 
          -atime +7 -exec rm {} ; 
    

    Example 3 Printing All File Names But Skipping SCCS Directories

    The following command recursively print all file names in the current directory and below, but skipping SCCS directories:

    example% find . -name SCCS -prune -o -print
    

    Example 4 Printing all file names and the SCCS directory name

    Recursively print all file names in the current directory and below, skipping the contents of SCCS directories, but printing out the SCCS directory name:

    example% find . -print -name SCCS -prune
    

    Example 5 Testing for the Newer File

    The following command is basically equivalent to the -nt extension to test(1):

    example$ if [ -n "$(find
    file1 -prune -newer file2)" ]; then
    
    printf %s\n "file1 is newer than file2"
    

    Example 6 Selecting a File Using 24-hour Mode

    The descriptions of -atime, -ctime, and -mtime use the terminology n «24-hour periods». For example, a file accessed at 23:59 is selected by:

    example% find . -atime -1 -print
    

    at 00:01 the next day (less than 24 hours later, not more than one day ago). The midnight boundary between days has no effect on the 24-hour calculation.

    Example 7 Printing Files Matching a User’s Permission Mode

    The following command recursively print all file names whose permission mode exactly matches read, write, and execute access for user, and read and execute access for group and other:

    example% find . -perm u=rwx,g=rx,o=rx
    

    The above could alternatively be specified as follows:

    example% find . -perm a=rwx,g-w,o-w
    

    Example 8 Printing Files with Write Access for other

    The following command recursively print all file names whose permission includes, but is not limited to, write access for other:

    example% find . -perm -o+w
    

    Example 9 Printing Local Files without Descending Non-local Directories

    example% find . ! -local -prune -o -print
    

    Example 10 Printing the Files in the Name Space Possessing Extended Attributes

    example% find . -xattr
    

    ENVIRONMENT VARIABLES

    See environ(5) for descriptions of the following environment variables that affect the execution of find: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH.

    PATH

    Determine the location of the utility_name for the -exec and -ok primaries.

    Affirmative responses are processed using the extended regular expression defined for the yesexpr keyword in the LC_MESSAGES category of the user’s locale. The locale specified in the LC_COLLATE category defines the behavior of ranges, equivalence
    classes, and multi-character collating elements used in the expression defined for yesexpr. The locale specified in LC_CTYPE determines the locale for interpretation of sequences of bytes of text data a characters, the behavior of character classes used in
    the expression defined for the yesexpr. See locale(5).
     

    EXIT STATUS

    The following exit values are returned:

    0

    All path operands were traversed successfully.

    >0

    An error occurred.

    FILES

    /etc/passwd

    Password file

    /etc/group

    Group file

    /etc/dfs/fstypes

    File that registers distributed file system packages

    ATTRIBUTES

    See attributes(5) for descriptions of the following attributes:

    ATTRIBUTE TYPE ATTRIBUTE VALUE

    Availability SUNWcsu

    CSI

    Interface Stability

    Standard

    SEE ALSO

    chmod(1), cpio(1), sh(1), test(1), ls(1B), acl(2), stat(2), umask(2), attributes(5), environ(5), fsattr(5), largefile(5), locale(5), standards(5)
     

    WARNINGS

    The following options are obsolete and will not be supported in future releases:

    -cpio device

    Always true. Writes the current file on device in cpio format (5120-byte records).

    -ncpio device

    Always true. Writes the current file on device in cpio -c format (5120-byte records).

    NOTES

    When using find to determine files modified within a range of time, use the -mtime argument before the -print argument. Otherwise, find gives all files.

    Some files that might be under the Solaris root file system are actually mount points for virtual file systems, such as mntfs or namefs. When comparing against a ufs file system, such files are not selected if -mount or -xdev is specified in the find expression.

    Using the -L or -follow option is not recommended when descending a file-system hierarchy that is under the control of other users. In particular, when using -exec, symbolic links can lead the find command out of the hierarchy
    in which it started. Using -type is not sufficient to restrict the type of files on which the -exec command operates, because there is an inherent race condition between the type-check performed by the find command and the time the executed command
    operates on the file argument.


     

    Index

    NAME
    SYNOPSIS
    DESCRIPTION
    OPTIONS
    OPERANDS
    Expressions
    Complex Expressions
    USAGE
    EXAMPLES
    ENVIRONMENT VARIABLES
    EXIT STATUS
    FILES
    ATTRIBUTES
    SEE ALSO
    WARNINGS
    NOTES

    Понравилась статья? Поделить с друзьями:
  • Find word in array c
  • Find word from string java
  • Find word from picture
  • Find word from other words
  • Find word from letters program