p4 grep

Synopsis

Print lines in files (or revisions of files) that match a pattern.

Syntax

p4 [g-opts] grep [-a -i -n -s -t] [-v | -l | -L] [-F | -G] [-A num] [-B num] [-C num]
                 -e pattern file[revRange] ...

Description

The p4 grep command searches for lines that match a given regular expression.

By default, p4 grep operates on the head revision. If the file argument specifies a revision, all files as of that revision number are searched. If the file argument has a revision range, only those files selected by that revision range are searched, and the highest revision in that range is used for each file.

By default, p4 grep searches at most 10,000 revisions. This limit is controlled by the dm.grep.maxrevs configurable.

The following example shows you can find all occurrences of a whole word:

$ p4 grep -e "voodoo" //depot/main/myDir/...

Options

-a

Search all revisions within the specified range, rather than only the highest revision in the range.

-A num

Display num lines of trailing context after matching lines.

-B num

Display num lines of trailing context before matching lines.

-C num

Display num lines of output context.

-e pattern

The patterns used by p4 grep are regular expressions comparable to those used in UNIX; their syntax is fully defined in the output of p4 help grep.

-F

Interpret the pattern as a fixed string.

-G

Interpret the pattern as a regular expression.

-i

Perform case-insensitive pattern matching. (By default, matching is case-sensitive.)

-L

Display the name of each selected file from which no output would normally have been displayed; scanning stops at the first match.

-n

Display a matching line number after the file revision number.

-v

Display files with non-matching lines.

-l

Display the name of each selected file from which output would have been displayed; scanning stops at the first match.

-s

Suppress error messages from files with more than 4096 characters in a single line. (By default, p4 grep abandons these files and reports an error)

-t

Treat binary files as text. (By default, only files of type text are selected for pattern matching.)

g-opts

See “Global Options”.

Usage Notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required

N/A

N/A

read