Title: Theory / Unimportant / CS / command line / text streaming / grep
Tags: computer_to_instruction fromCommandLine hasNotNewEffectReturnsMeaning mid1516974248815 récupéré
On every note of this deck, unless a note says otherwise:
Page: man

Instruction: grep foo
Page: man
Effect: Search for pattern foo in the standard input
Context: command line

Instruction: grep foo bar_1 ... bar_n
Page: man
Effect: Search for pattern foo in the bar_i

Instruction: egrep
Page: man
Effect: abbreviation for grep -E

Instruction: fgrep
Page: man
Effect: abbreviation for grep -F

Fla: --help
Effect: Print a usage message briefly summarizing these command-line options and the bug-reporting address, then exit.
Prefix: grep

Fla: --version
Effect: Print the version number of grep to the standard output stream. This version number should be included in all bug reports (see below).
Prefix: grep
Flag abbreviation: -V

Fla: --extended-regexp
Effect: Interpret PATTERN as an extended regular expression
Prefix: grep PATTERN
Flag abbreviation: -E

Fla: --fixed-strings
Effect: Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
Prefix: grep PATTERN
Flag abbreviation: -F

Fla: --basic-regexp
Effect: Interpret PATTERN as a basic regular expression
Prefix: grep PATTERN
Flag abbreviation: -G

Fla: --perl-regexp
Effect: Interpret PATTERN as a Perl regular expression. This is highly experimental and it may warn of unimplemented features.
Prefix: grep PATTERN
Flag abbreviation: -P

Fla: --regexp=foo
Effect: Use foo as the pattern. (This can be used to specify multiple search patterns, or to protect a pattern beginning with a hyphen (-). )
Prefix: grep
Flag abbreviation: -e foo

Fla: --file=foo
Effect: Obtain patterns from foo, one per line. The empty file contains zero patterns, and therefore matches nothing.
Prefix: grep
Flag abbreviation: -f foo

Fla: --ignore-case
Effect: Ignore case distinctions in both the PATTERN and the input files.
Prefix: grep PATTERN input_files
Flag abbreviation: -i

Fla: --invert_match
Effect: Invert the sense of matching, to select non-matching lines.
Prefix: grep PATTERN input_files
Flag abbreviation: -v

Fla: --word-regexp
Effect: Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore.
Prefix: grep PATTERN input_files
Flag abbreviation: -w

Fla: --line-regexp
Effect: Select only those matches that exactly match the whole line.
Prefix: grep PATTERN input_files
Flag abbreviation: -x

Fla: --count
Effect: Suppress normal output; instead print a count of matching lines for each input file.
Prefix: grep PATTERN input_files
Flag abbreviation: -c

Fla: --color, --colour
Effect: Surround the matched (non-empty) strings, matching lines, context lines, file names, line numbers, byte offsets, and separators (for fields and groups of context lines) with escape sequences to display them in color on the terminal. The colors are defined by the environment variable GREP_COLORS.
Prefix: grep PATTERN input_files

Variable: GREP_COLORS
Meaning: Colors to use for grep --color
Page: man
Context: grep PATTERN input_files
Kind: environment variable

Fla: --files-without-match
Effect: Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The scanning will stop on the first match.
Prefix: grep PATTERN input_files
Flag abbreviation: -L

Fla: --files-with-match
Effect: Only print file name and not the matched line
Prefix: grep PATTERN input_files
Flag abbreviation: -l

Fla: --max-count=foo
Effect: Stop reading a file after foo matching lines.
Prefix: grep PATTERN input_files
Flag abbreviation: -m foo

Fla: --only_matching
Effect: Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
Prefix: grep PATTERN input_files
Flag abbreviation: -o

Fla: --quiet, --silent
Effect: Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected.
Prefix: grep PATTERN input_files
Flag abbreviation: -q

Fla: --no-messages
Effect: Suppress error messages about nonexistent or unreadable files.
Prefix: grep PATTERN input_files
Flag abbreviation: -s