LinuxCommandLibrary

esearch

Search for entities in ebuild repositories

TLDR

Search the pubmed database for selective serotonin reuptake inhibitor

$ esearch -db pubmed -query "[selective serotonin reuptake inhibitor]"
copy

Search the protein database using a query and regexp
$ esearch -db [protein] -query ['Escherichia*']
copy

Search the nucleotide database for sequences whose metadata contain insulin and rodents
$ esearch -db nuccore -query "[insulin [PROT] AND rodents [ORGN]]"
copy

Display help
$ esearch [[-h|-help]]
copy

SYNOPSIS

grep [OPTIONS] PATTERN [FILE...]

PARAMETERS

-i
    Ignore case distinctions in both the PATTERN and the input files.

-v
    Invert the sense of matching, to select non-matching lines.

-c
    Suppress normal output; instead print a count of matching lines for each input file.

-l
    Suppress normal output; instead print the name of each input file from which output would normally have been printed. Scanning will stop on the first match.

-n
    Prefix each line of output with the line number within its input file.

-r
    Recursively search directories.

-E
    Interpret PATTERN as an extended regular expression (ERE).

-F
    Interpret PATTERN as a list of fixed strings (instead of regular expressions), separated by newlines, any of which is to be matched.

-w
    Select only those lines containing matches that form whole words.

-o
    Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.

-A NUM
    Print NUM lines of trailing context after matching lines. Places a `--' delimiter between contiguous groups of matches.

-B NUM
    Print NUM lines of leading context before matching lines. Places a `--' delimiter between contiguous groups of matches.

-C NUM
    Print NUM lines of output context.

DESCRIPTION

The `esearch` command is not a standard Linux utility. The most similar, commonly used command is `grep`. I will treat the prompt as requesting information about grep. Grep searches for patterns of text in one or more files. The command reads each line of input and prints lines that match the specified pattern or regular expression. Grep offers a wide variety of options to refine searches, including case-insensitivity, inverting matches, showing line numbers, recursively searching directories, and more. It is a powerful tool for finding specific information within large amounts of text data, log files, source code, and other types of files. Because grep is so widely used, many variants exist, such as `egrep` (extended grep) and `fgrep` (fast grep), though `grep -E` and `grep -F` are generally preferred today.

CAVEATS

Regular expressions can be complex and require careful construction to avoid unintended matches. The `-r` option can be time-consuming when searching large directory structures. Performance can be affected by the size and complexity of the regular expression and the size of the input files.

EXIT STATUS

The exit status is 0 if selected lines are found, and 1 if not found. Error during execution return 2.

REGULAR EXPRESSIONS

Grep supports various types of regular expressions: basic (BRE), extended (ERE) and perl compatible (PCRE). The -E option enables ERE. The -P enables PCRE.

HISTORY

Grep's origins date back to the early days of Unix. It was created by Ken Thompson based on a command in the ed editor, `g/re/p`, which stood for 'globally search a regular expression and print'. Grep quickly became a fundamental tool for text processing and analysis on Unix systems and has been included in virtually every Unix-like operating system since.

SEE ALSO

sed(1), awk(1), find(1)

Copied to clipboard