patch [options] [sourcefile [patchfile]]Solaris only. patch reads a "patch" containing the output of diff in normal, ed-script, or context format, and applies the changes contained therein to the original version of sourcefile. Multiple files can be patched, but it must be possible to determine the name of the original file from the contents of the patch. Distributing patches is an easy way to provide upgrades to source file distributions where the changes are small relative to the size of the entire distribution.
Note: this entry documents the Solaris version, which is a somewhat older version of Larry Wall's original patch program. The Free Software Foundation now maintains patch. Newer, more capable versions are available from them and are recommended; see http://www.gnu.org.
-bMake a backup of each file, in file.orig. An existing file.orig is overwritten.
-cThe patchfile is a context diff (from diff -c or diff -C).
-d dirChange directory to dir before applying the patch.
-D identifierBracket changes with C preprocessor #ifdef.
#ifdef identifier ... #endif
-eThe patchfile is an ed script (from diff -e).
-i fileRead the patch from file instead of from standard input.
-lPatch loosely. Any sequence of whitespace characters in the patch may match any sequence of whitespace in sourcefile. Other characters must match exactly.
-nThe patchfile is a normal diff (from diff with no special options).
-NIgnore patches that have already been applied. Normally, such patches are rejected.
-o newfileInstead of updating each source file in place, write the full contents of the modified file(s) to newfile. If a file is updated multiple times, newfile will contain a copy of each intermediate version.
-pNRemove N leading pathname components from the filename used in the patch. The leading / of a full pathname counts as one component. Without this option, only the final filename part of the filename is used.
-r rejfileUse rejfile to contain patches that could not be applied, instead of file.rej. Rejected patches are always in context diff format.
-RReverse the sense of the patch. In other words, assume that the patch was created using diff new old, instead of diff old new.
Update a software distribution:
$cd whizprog-1.1$patch -p1 < whizprog-1.1-1.2.diffLots of messages here as patch works $find . -name '*.orig' -print | xargs rm$cd ..$mv whizprog-1.1 whizprog-1.2