[ << ] | [ < ] | [ 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.
- ‘-b’
- ‘--byte-offset’
-
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. - ‘-H’
- ‘--with-filename’
-
Print the file name for each match. This is the default when there is more than one file to search.
- ‘-h’
- ‘--no-filename’
-
Suppress the prefixing of file names on output. This is the default when there is only one file (or only standard input) to search.
- ‘--label=LABEL’
-
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
- ‘-n’
- ‘--line-number’
-
Prefix each line of output with the 1-based line number within its input file. (‘-n’ is specified by POSIX.)
- ‘-T’
- ‘--initial-tab’
-
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.
- ‘-u’
- ‘--unix-byte-offsets’
-
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 theCR
characters that were stripped. This will produce results identical to runninggrep
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. - ‘-Z’
- ‘--null’
-
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 June 7, 2014 using texi2html 5.0.