grep: Output Line Prefix Control

1 
1 2.1.4 Output Line Prefix Control
1 --------------------------------
1 
1 When several prefix fields are to be output, the order is always file
1 name, line number, and byte offset, regardless of the order in which
1 these options were specified.
1 
1 ‘-b’
1 ‘--byte-offset’
1      Print the 0-based byte offset within the input file before each
1      line of output.  If ‘-o’ (‘--only-matching’) is specified, print
1      the offset of the matching part itself.
1 
1 ‘-H’
1 ‘--with-filename’
1      Print the file name for each match.  This is the default when there
1      is more than one file to search.
1 
1 ‘-h’
1 ‘--no-filename’
1      Suppress the prefixing of file names on output.  This is the
1      default when there is only one file (or only standard input) to
1      search.
1 
1 ‘--label=LABEL’
1      Display input actually coming from standard input as input coming
1      from file LABEL.  This is especially useful when implementing tools
1      like ‘zgrep’; e.g.:
1 
1           gzip -cd foo.gz | grep --label=foo -H something
1 
1 ‘-n’
1 ‘--line-number’
1      Prefix each line of output with the 1-based line number within its
1      input file.  (‘-n’ is specified by POSIX.)
1 
1 ‘-T’
1 ‘--initial-tab’
1      Make sure that the first character of actual line content lies on a
1      tab stop, so that the alignment of tabs looks normal.  This is
1      useful with options that prefix their output to the actual content:
1      ‘-H’, ‘-n’, and ‘-b’.  This may also prepend spaces to output line
1      numbers and byte offsets so that lines from a single file all start
1      at the same column.
1 
1 ‘-Z’
1 ‘--null’
1      Output a zero byte (the ASCII NUL character) instead of the
1      character that normally follows a file name.  For example, ‘grep
1      -lZ’ outputs a zero byte after each file name instead of the usual
1      newline.  This option makes the output unambiguous, even in the
1      presence of file names containing unusual characters like newlines.
1      This option can be used with commands like ‘find -print0’, ‘perl
1      -0’, ‘sort -z’, and ‘xargs -0’ to process arbitrary file names,
1      even those that contain newline characters.
1