Go to the first, previous, next, last section, table of contents.

Invoking patch

Normally patch is invoked like this:

patch <patchfile

The full format for invoking patch is:

patch options... [origfile [patchfile]] [+ options... [origfile]]...

If you do not specify patchfile, or if patchfile is `-', patch reads the patch (that is, the diff output) from the standard input.

You can specify one or more of the original files as orig arguments; each one and options for interpreting it is separated from the others with a `+'. See section Multiple Patches in a File, for more information.

If you do not specify an input file on the command line, patch tries to figure out from the leading text (any text in the patch that comes before the diff output) which file to edit. In the header of a context or unified diff, patch looks in lines beginning with `***', `---', or `+++'; among those, it chooses the shortest name of an existing file. Otherwise, if there is an `Index:' line in the leading text, patch tries to use the file name from that line. If patch cannot figure out the name of an existing file from the leading text, it prompts you for the name of the file to patch.

If the input file does not exist or is read-only, and a suitable RCS or SCCS file exists, patch attempts to check out or get the file before proceeding.

By default, patch replaces the original input file with the patched version, after renaming the original file into a backup file (see section Backup File Names, for a description of how patch names backup files). You can also specify where to put the output with the `-o output-file' or `--output=output-file' option.


Go to the first, previous, next, last section, table of contents.