patch


patch

Purpose

Apply the output of the diff command to an original file.

Syntax

patch [options] < patch_file

Options

-c causes the patch file to be interpreted as a context diff.

-e forces patch to interpret the patch file as an ed script.

-f forces patch to be applied regardless of any inconsistencies.

-n causes the patch file to be interpreted as a normal diff.

-pn strips everything up to n slashes in the pathname.

-R indicates that patch file has been created with new and old files swapped.

-u causes the patch file to be interpreted as a unified diff.

-v displays the version number.

Description

The patch command is used to update an original file by applying all the differences between the original and a revised version. The differences are in the form of an output from the diff command, stored in the patch_file. Changes to Linux kernel source code are distributed in the form of a patch file. Chapter 21 discusses how to apply patches to the kernel source.