grep (target)
Search for string patterns (POSIX, toybox)
Syntax:
grep [-abcEFHhIiLlnoqrsvwxZz] [-ABC num] [-m max] [-e regex]...
[--exclude-dir pattern]... [-MS pattern]... [-f regfile] [file]...
Runs on:
QNX OS
Options:
- -A num
- Show the specified number of lines after each match.
- -a
- Always match text (not binary).
- -B num
- Show num lines before each match.
- -b
- Display byte offset of a match.
- -C num
- Show num lines of context surrounding each match (see also the -A and -B options).
- -c
- Write only a count of matching lines to standard output.
- -E
- Extended regular expression syntax.
- -e regex
- Regular expression or expressions to match.
- --exclude-dir=pattern
- Skip directories with the specified pattern.
- -F
- Interpret patterns as a set of fixed strings (a literal match).
- -f regfile
- File or files that list the regular expressions to match (one per line).
- -H
- Always print the filename for each match.
- -h
- Hide the filename.
- -I
- Ignore binary files.
- -i
- Perform case insensitive matching.
- -L
- Only the names of files not containing matching lines are written to standard output.
- -l
- ("el") Only the names of files containing matching lines are written to standard output.
- -M, --include pattern
- Match filename to pattern.
- -m max
- Specify the maximum number of lines to match.
- -n
- Prefix each match with its line number.
- -o
- Print only the matching part of the lines.
- -q
- Be quiet; suppress normal output and only print error messages.
- -R
- Read recursively, following symbolic links.
- -r
- Recursively read files under all subdirectories.
- -S, --exclude pattern
- Skip filenames that match the specified pattern.
- -s
- Be silent; suppress all error messages.
- -v
- Selected lines are those not matching any of the specified patterns.
- -w
- The expression is searched for as a whole word (this implies the -E option).
- -x
- Only input lines selected against an entire fixed string or regular expression are considered to be matching lines.
- -Z
- Treat output data as NULL terminated.
- -z
- Treat input data as NULL terminated.
- file
- The text file to be input.
Description:
The grep utility searches input for lines matching the expression(s) given
and writes them to standard output. If there is no -e, the first argument
is regular expression to match. If you do not specify a file (or filename is a hyphen
(-
)), grep reads from the standard input. Returns 0 if
matched, 1 if no match found, 2 for command errors.
This utility is provided as part of the toybox package. For information on how to enable it, see toybox.
Contributing author:
Rob Landley and the toybox project (see https://landley.net/toybox/).
Page updated: