Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)
patch(1) OSS Shell and Utilities Reference Manual
If number is omitted or 0, then the pathname is not modified. If the -p flag is
omitted, all slashes and directory names preceding the filename are stripped.
For example, if the filename in the patch file was /u/howard/src/blurfl/blurfl.c,
entering -p or -p0 leaves the entire pathname unmodified. Entering -p1 results in
u/howard/src/blurfl/blurfl.c without the leading slash. Entering -p4 results in
blurfl/blurfl.c. Omitting -p from the patch command line results in blurfl.c.
The patch command looks for the resulting pathname in either the current direc-
tory or the directory specified by the -d flag.
-r rejectfile Specifies the filename of the reject file. By default, the reject file has the same
name as the output file, with the suffix .rej appended.
-R Reverses the sense of the patch script; that is, patch assumes that the diff script
was created by comparing the new version to the old version. The patch com-
mand tries to reverse each portion of the script before applying it. Rejected
differences are saved in swapped format.
If this flag is not specified, then until a portion of the patch file is successfully
applied, patch tries to apply each portion in its reversed sense as well as in its
normal sense. If the attempt is successful, you are prompted to determine
whether -R should be set.
Note that this method cannot detect a reversed patch if it is a normal diff script
and if the first command is an append (that is, it should have been a delete):
appends always succeed because a NULL context matches anywhere. However,
most patches add or change lines rather than delete them, so most reversed nor-
mal diff scripts begin with a delete, which will fail, triggering the heuristic.
-s Patches silently unless an error occurs.
-S Ignores a patch from the patch file, but continues looking for the next patch in
the file. For example
patch -S + -S + <patchfile
ignores the first and second patches in patchfile.
-v Prints out the revision header and patch level.
+ flags [original_file]
Specifies flags (and possibly another original filename) for the second and subse-
quent patches. The argument list for each patch must be preceded with + (plus
sign). (Note that the argument list for a second or subsequent patch may not
specify a new patch file.)
Operands
original_file Specifies the file to be patched.
DESCRIPTION
The patch command takes a patch file that contains either of the forms of difference listing pro-
duced by the diff program (normal or context) and applies those differences to an original file,
producing a patched version.
By default, the patched version of a file replaces the original. The original file can be backed up
to the same name with the extension .orig by specifying the -b flag. You can also specify where
you want the output to go with the -o flag. If the -i patchfile flag is not specified, or if patchfile is
- (dash), the patch is read from the standard input file.
7−8 Hewlett-Packard Company 527188-004