manpagez: man pages & more
info grep
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1.4 Output Line Prefix Control

When several prefix fields are to be output, the order is always file name, line number, and byte offset, regardless of the order in which these options were specified.


Print the 0-based byte offset within the input file before each line of output. If ‘-o’ (‘--only-matching’) is specified, print the offset of the matching part itself. When 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.


Print the file name for each match. This is the default when there is more than one file to search.


Suppress the prefixing of file names on output. This is the default when there is only one file (or only standard input) to search.


Display input actually coming from standard input as input coming from file LABEL. This is especially useful when implementing tools like zgrep; e.g.:

gzip -cd foo.gz | grep --label=foo -H something

Prefix each line of output with the 1-based line number within its input file. (‘-n’ is specified by POSIX.)


Make sure that the first character of actual line content lies on a tab stop, so that the alignment of tabs looks normal. This is useful with options that prefix their output to the actual content: ‘-H’, ‘-n’, and ‘-b’. In order to improve the probability that lines from a single file will all start at the same column, this also causes the line number and byte offset (if present) to be printed in a minimum-size field width.


Report Unix-style byte offsets. This option causes grep to report byte offsets as if the file were a Unix-style text file, i.e., the byte offsets ignore the CR characters that were stripped. This will produce results identical to running grep on a Unix machine. This option has no effect unless the ‘-b’ option is also used; it has no effect on platforms other than MS-DOS and MS-Windows.


Output a zero byte (the ASCII 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.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on November 17, 2011 using texi2html 5.0.

© 2000-2018
Individual documents may contain additional copyright information.