Next: Invoking sdiff
, Previous: Invoking diff3
, Up: Comparing and Merging Files [Contents][Index]
patch
Normally patch
is invoked like this:
patch <patchfile
The full format for invoking patch
is:
patch options… [origfile [patchfile]]
You can also specify where to read the patch from with the -i
patchfile or --input=patchfile option.
If you do not specify patchfile, or if patchfile is
-, patch
reads the patch (that is, the diff
output)
from the standard input.
If you do not specify an input file on the command line, patch
tries to intuit from the leading text (any text in the patch
that comes before the diff
output) which file to edit.
See Multiple Patches in a File.
By default, patch
replaces the original input file with the
patched version, possibly after renaming the original file into a
backup file (see Backup File Names, for a description of how
patch
names backup files). You can also specify where to
put the output with the -o file or
--output=file option; however, do not use this option
if file is one of the input files.
Up: Invoking patch
[Contents][Index]
patch
Here is a summary of all of the options that GNU patch
accepts. See GNU patch
and Traditional patch
, for which of these options are
safe to use in older versions of patch
.
Multiple single-letter options that do not take an argument can be combined into a single command line argument with only one dash.
Back up the original contents of each file, even if backups would normally not be made. See Backup Files.
Prepend prefix to backup file names. See Backup File Names.
Back up the original contents of each file if the patch does not exactly match the file. This is the default behavior when not conforming to POSIX. See Backup Files.
Read and write all files in binary mode, except for standard output and /dev/tty. This option has no effect on POSIX-conforming systems like GNU/Linux. On systems where this option makes a difference, the patch should be generated by ‘diff -a --binary’. See Binary Files and Forcing Text Comparisons.
Interpret the patch file as a context diff. See Selecting the patch
Input Format.
Make directory directory the current directory for interpreting both file names in the patch file, and file names given as arguments to other options. See Applying Patches in Other Directories.
Make merged if-then-else output using name. See Merging Files with If-then-else.
Print the results of applying the patches without actually changing
any files. See Predicting what patch
will do.
Interpret the patch file as an ed
script. See Selecting the patch
Input Format.
Remove output files that are empty after the patches have been applied. See Creating and Removing Files.
Assume that the user knows exactly what he or she is doing, and do not
ask any questions. See Messages and Questions from patch
.
Set the maximum fuzz factor to lines. See Helping patch
Find Inexact Matches.
If num is positive, get input files from a revision control system as necessary; if zero, do not get the files; if negative, ask the user whether to get the files. See Revision Control.
Output a summary of usage and then exit.
Read the patch from patchfile rather than from standard input.
See Options to patch
.
Let any sequence of blanks (spaces or tabs) in the patch file match any sequence of blanks in the input file. See Applying Patches with Changed White Space.
Interpret the patch file as a normal diff. See Selecting the patch
Input Format.
Ignore patches that patch
thinks are reversed or already applied.
See also -R. See Applying Reversed Patches.
Do not back up the original contents of files. This is the default behavior when conforming to POSIX. See Backup Files.
Use file as the output file name. See Options to patch
.
Set the file name strip count to number. See Applying Patches in Other Directories.
Conform to POSIX, as if the POSIXLY_CORRECT
environment
variable had been set. See patch
and the POSIX Standard.
Use style word to quote names in diagnostics, as if the
QUOTING_STYLE
environment variable had been set to word.
See patch
Quoting Style.
Use reject-file as the reject file name. See Reject File Names.
Assume that this patch was created with the old and new files swapped. See Applying Reversed Patches.
Work silently unless an error occurs. See Messages and Questions from patch
.
Do not ask any questions. See Messages and Questions from patch
.
Set the modification and access times of patched files from timestamps given in context diff headers, assuming that the context diff headers use local time. See Updating Timestamps on Patched Files.
Interpret the patch file as a unified diff. See Selecting the patch
Input Format.
Output version information and then exit.
Select the naming convention for backup file names. See Backup File Names.
Print more diagnostics than usual. See Messages and Questions from patch
.
Set internal debugging flags. Of interest only to patch
patchers.
Prepend prefix to base names of backup files. See Backup File Names.
Use suffix as the backup extension instead of ‘.orig’ or ‘~’. See Backup File Names.
Set the modification and access times of patched files from timestamps given in context diff headers, assuming that the context diff headers use UTC. See Updating Timestamps on Patched Files.
Next: Invoking sdiff
, Previous: Invoking diff3
, Up: Comparing and Merging Files [Contents][Index]