[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
grep
to the standard output stream.
This version number should be included in all bug reports.
grep
normally outputs either
a one-line message saying that a binary file matches, or no message if
there is no match. If type is `without-match',
grep
assumes that a binary file does not match;
this is equivalent to the `-I' option. If type
is `text', grep
processes a binary file as if it were
text; this is equivalent to the `-a' option.
Warning: `--binary-files=text' might output binary garbage,
which can have nasty side effects if the output is a terminal and if the
terminal driver interprets some of it as commands.
grep
runs on MS-DOS or MS-Windows, the printed
byte offsets
depend on whether the `-u' (`--unix-byte-offsets') option is
used; see below.
grep
to print error
messages for every directory or silently skip them). If action is
`skip', directories are silently skipped. If action is
`recurse', grep
reads all files under each directory,
recursively; this is equivalent to the `-r' option.
gzip -cd foo.gz |grep --label=foo something
grep
ensures that the standard input is positioned to
just after the last matching line before exiting, regardless of the
presence of trailing context lines. This enables a calling process
to resume a search. For example, the following shell script makes use
of it:
while grep -m 1 PATTERN do echo xxxx done < FILE |
But the following probably will not work because a pipe is not a regular file:
# This probably will not work. cat FILE | while grep -m 1 PATTERN do echo xxxx done |
When grep
stops after NUM matching lines, it outputs
any trailing context lines. Since context does not include matching
lines, grep
will stop when it encounters another matching line.
When the `-c' or `--count' option is also used,
grep
does not output a count greater than num.
When the `-v' or `--invert-match' option is
also used, grep
stops after outputting num
non-matching lines.
grep
guesses the file type by looking
at the contents of the first 32kB read from the file.
If grep
decides the file is a text file, it strips the
CR
characters from the original file contents (to make
regular expressions with ^
and $
work correctly).
Specifying `-U' overrules this guesswork, causing all
files to be read and passed to the matching mechanism
verbatim; if the file is a text file with CR/LF
pairs
at the end of each line, this will cause some regular
expressions to fail. This option has no effect on platforms other than
MS-DOS and MS-Windows.
grep
to report byte offsets as if the file were Unix style
text file, i.e., the byte offsets ignore the CR
characters which were
stripped. This will produce results identical to running grep
on
a Unix machine. This option has no effect unless `-b'
option is also used; it has no effect on platforms other than MS-DOS and
MS-Windows.
mmap
system call to read input, instead of
the default read
system call. In some situations, `--mmap'
yields better performance. However, `--mmap' can cause undefined
behavior (including core dumps) if an input file shrinks while
grep
is operating, or if an I/O error occurs.
NUL
character) instead of the
character that normally follows a file name. For example, `grep
-lZ' outputs a zero byte after each file name instead of the usual
newline. This option makes the output unambiguous, even in the presence
of file names containing unusual characters like newlines. This option
can be used with commands like `find -print0', `perl -0',
`sort -z', and `xargs -0' to process arbitrary file names,
even those that contain newline characters.
NUL
character) instead of a newline. Like the `-Z'
or `--null' option, this option can be used with commands like
`sort -z' to process arbitrary file names.
Several additional options control which variant of the grep
matching engine is used. See section 4. grep
programs.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |