p4 print
Print the contents of a depot file revision.
Syntax
p4 [g-opts] print [-a -A -k -q] [-m max] [-o outfile] FileSpec[revSpec]
p4 [g-opts] print -U unload FileSpec
Description
The p4 print
command writes the contents of a depot
file to standard output.
A revision range can be included. In this case, only the files with revisions in the specified range are printed. By default, only the highest revision in that range is printed.
To output
a file at every revision within a specified revision range, such as versions 2
, 3
, and 4
of readme.txt
:
p4 print -a readme.txt#2,4
The output is the contents of readme.txt#4
, followed by the contents of readme.txt#3
, and concluding with the contents of readme.txt#2
.
To get solely version 3
:
p4 print -a readme.txt#3,3
To get all the versions up to version 3
:
p4 print -a readme.txt#3
To all the versions there are:
p4 print -a readme.txt#head
Multiple file patterns can be included. All files matching any of the patterns are printed.
Any file in the depot can be printed, subject to permission limitations
as granted by p4
protect
.
If the file argument does not map through the client view, you must provide it in depot syntax.
By default, the file is written with a header that describes the
location of the file in the depot, the revision number of the printed
file, and the number of the changelist that the revision was submitted
under. To suppress the header, use the -q
(quiet)
option.
By default, RCS keywords are expanded. To suppress keyword expansion,
use the -k
(keyword) option.
By default, the local depot is searched for the specified file. If you
specify the -U
option, the unload depot is searched
instead.
Options
|
For each file, print all revisions within a specified revision range, rather than only the highest revision in the range. |
|
Attempt to print a file stored in an archive depot. |
|
Suppress RCS keyword expansion. |
|
Print only the first |
|
Redirect output to the specified output file (outfile) on the local disk. This preserves the same file type, attributes, and/or permission bits as the original file (FileSpec) in the depot. Multiple files can be written by using wildcards in the localFile argument that match wildcards in the depot (FileSpec) argument. For example: To print the contents of a directory and directories under that directory, use the ... wildcard: $ p4 print -o c:/tmp/main-copy/... //depot/main/... To print all files that match readme.txt or readme.pdf, you might specify $ p4 print -o readme.* //depot/readme.* |
|
Suppress the one-line file header normally added by Helix Server. |
|
Look for the specified file or files in the unload depot. Data about an unloaded client, label, or task stream can be printed. |
|
See Global options. |
Usage Notes
Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required |
---|---|---|
Yes |
Yes |
|
-
Because most terminals are unable to display UTF16 content, the default behavior of the
p4 print
command is to return UTF8 content. You can override this behavior by bypassing terminal output entirely and specifying an output file, for example:$ p4 print -q -o outputfile //depot/file
If your terminal supports UTF16 output, specify standard output as the output file:
$ p4 print -q -o - //depot/file
- p4 print's file arguments can take a revision
range. By default, only the highest revision matched by any particular
file is printed (that is, when no range is specified, the implied range
is
#1,#head
, and the highest revision is#head
). To print all files in a specified (or implied) range, use the-a
option. - Because
p4 print
's output can be quite large when called with highly non-restrictive file arguments (for instance,p4 print //depot/...
prints the contents of all files in the depot), it may be subject to amaxresults
limitation as set inp4 group
. -
In many cases, redirecting
p4 print
's output to a file via your OS shell will suffice.The
-o
option is intended for users who require the automatic setting of file type and/or permission bits. This is useful for files such as symbolic links (stored as typesymlink
), files of typeapple
, automatically setting the execute bit on UNIX shell scripts stored as typetext+x
, and so on.
Related Commands
To compare the contents of two depot file revisions |
|
To compare the contents of an opened file in the client workspace to a depot file revision |