Go to the first, previous, next, last section, table of contents.
Normally @command{patch} is invoked like this:
patch <patchfile
The full format for invoking @command{patch} is:
patch options... [origfile [patchfile]]
You can also specify where to read the patch from with the @option{-i
patchfile} or @option{--input=patchfile} option.
If you do not specify patchfile, or if patchfile is
`-', @command{patch} reads the patch (that is, the @command{diff} output)
from the standard input.
If you do not specify an input file on the command line, @command{patch}
tries to intuit from the leading text (any text in the patch
that comes before the @command{diff} output) which file to edit.
See section Multiple Patches in a File.
By default, @command{patch} replaces the original input file with the
patched version, possibly after renaming the original file into a
backup file (see section Backup File Names, for a description of how
@command{patch} names backup files). You can also specify where to
put the output with the @option{-o file} or
@option{--output=file} option; however, do not use this option
if file is one of the input files.
Here is a summary of all of the options that GNU @command{patch}
accepts. See section GNU @command{patch} and Traditional @command{patch}, for which of these options are
safe to use in older versions of @command{patch}.
Multiple single-letter options that do not take an argument can be
combined into a single command line argument with only one dash.
- @option{-b}
-
- @option{--backup}
-
Back up the original contents of each file, even if backups would
normally not be made. See section Backup Files.
- @option{-B prefix}
-
- @option{--prefix=prefix}
-
Prepend prefix to backup file names. See section Backup File Names.
- @option{--backup-if-mismatch}
-
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 section Backup Files.
- @option{--binary}
-
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 section Binary Files and Forcing Text Comparisons.
- @option{-c}
-
- @option{--context}
-
Interpret the patch file as a context diff. See section Selecting the @command{patch} Input Format.
- @option{-d directory}
-
- @option{--directory=directory}
-
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 section Applying Patches in Other Directories.
- @option{-D name}
-
- @option{--ifdef=name}
-
Make merged if-then-else output using name. See section Merging Files with If-then-else.
- @option{--dry-run}
-
Print the results of applying the patches without actually changing
any files. See section Predicting what @command{patch} will do.
- @option{-e}
-
- @option{--ed}
-
Interpret the patch file as an @command{ed} script. See section Selecting the @command{patch} Input Format.
- @option{-E}
-
- @option{--remove-empty-files}
-
Remove output files that are empty after the patches have been applied.
See section Creating and Removing Files.
- @option{-f}
-
- @option{--force}
-
Assume that the user knows exactly what he or she is doing, and do not
ask any questions. See section Messages and Questions from @command{patch}.
- @option{-F lines}
-
- @option{--fuzz=lines}
-
Set the maximum fuzz factor to lines. See section Helping @command{patch} Find Inexact Matches.
- @option{-g num}
-
- @option{--get=num}
-
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 section Revision Control.
- @option{--help}
-
Output a summary of usage and then exit.
- @option{-i patchfile}
-
- @option{--input=patchfile}
-
Read the patch from patchfile rather than from standard input.
See section Options to @command{patch}.
- @option{-l}
-
- @option{--ignore-white-space}
-
Let any sequence of blanks (spaces or tabs) in the patch file match
any sequence of blanks in the input file. See section Applying Patches with Changed White Space.
- @option{-n}
-
- @option{--normal}
-
Interpret the patch file as a normal diff. See section Selecting the @command{patch} Input Format.
- @option{-N}
-
- @option{--forward}
-
Ignore patches that @command{patch} thinks are reversed or already applied.
See also @option{-R}. See section Applying Reversed Patches.
- @option{--no-backup-if-mismatch}
-
Do not back up the original contents of files. This is the default
behavior when conforming to POSIX. See section Backup Files.
- @option{-o file}
-
- @option{--output=file}
-
Use file as the output file name. See section Options to @command{patch}.
- @option{-pnumber}
-
- @option{--strip=number}
-
Set the file name strip count to number. See section Applying Patches in Other Directories.
- @option{--posix}
-
Conform to POSIX, as if the @env{POSIXLY_CORRECT} environment
variable had been set. See section @command{patch} and the @sc{posix} Standard.
- @option{--quoting-style=word}
-
Use style word to quote names in diagnostics, as if the
@env{QUOTING_STYLE} environment variable had been set to word.
See section @command{patch} Quoting Style.
- @option{-r reject-file}
-
- @option{--reject-file=reject-file}
-
Use reject-file as the reject file name. See section Reject File Names.
- @option{-R}
-
- @option{--reverse}
-
Assume that this patch was created with the old and new files swapped.
See section Applying Reversed Patches.
- @option{-s}
-
- @option{--quiet}
-
- @option{--silent}
-
Work silently unless an error occurs. See section Messages and Questions from @command{patch}.
- @option{-t}
-
- @option{--batch}
-
Do not ask any questions. See section Messages and Questions from @command{patch}.
- @option{-T}
-
- @option{--set-time}
-
Set the modification and access times of patched files from time
stamps given in context diff headers, assuming that the context diff
headers use local time. See section Updating Time Stamps on Patched Files.
- @option{-u}
-
- @option{--unified}
-
Interpret the patch file as a unified diff. See section Selecting the @command{patch} Input Format.
- @option{-v}
-
- @option{--version}
-
Output version information and then exit.
- @option{-V backup-style}
-
- @option{--version=control=backup-style}
-
Select the naming convention for backup file names. See section Backup File Names.
- @option{--verbose}
-
Print more diagnostics than usual. See section Messages and Questions from @command{patch}.
- @option{-x number}
-
- @option{--debug=number}
-
Set internal debugging flags. Of interest only to @command{patch}
patchers.
- @option{-Y prefix}
-
- @option{--basename-prefix=prefix}
-
Prepend prefix to base names of backup files. See section Backup File Names.
- @option{-z suffix}
-
- @option{--suffix=suffix}
-
Use suffix as the backup extension instead of `.orig' or
`~'. See section Backup File Names.
- @option{-Z}
-
- @option{--set-utc}
-
Set the modification and access times of patched files from time
stamps given in context diff headers, assuming that the context diff
headers use UTC. See section Updating Time Stamps on Patched Files.
Go to the first, previous, next, last section, table of contents.