diff and patch-- File Differences
diff tool is used to create patches (sometimes called
diffs). A patch is a program (computer science definition) which
modifies text across one or more files. Typically these are used for
making changes to source code before it is compiled.
The simplest invocation is
diff -u oldfile newfile, which will
create a list of differences in unified format between
newfile. To operate over directories instead, use
-urN olddir newdir.
cvsprovide built-in diff functionality (
cvs diff) which may be more helpful.
For patches which go in the main tree, use unified (
format. This is generally the best format to use when sending patches
however, occasionally you may be asked to provide
context diffs, which are more portable than unifieds (but don't handle
conflicts as cleanly). In this case, use
To apply a patch, use
patch -pX < whatever.patch,
X is a number representing the number of path components
which must be removed (typically this is
ebuilds, use the
epatch function instead — see
Patching with epatch.
The diff-1 and patch-1 manual pages provide more information.