Report issue Add example

patch

Applies a patch file to original files.

Description

The patch command is used to apply patches (differences) to source files. It allows users to modify or update original files using a patch file generated by tools like diff. This is a common method for upgrading the Linux kernel or distributing software updates.

Syntax

patch [options] [original_file [patch_file]]

Options

-b, --backup: Make a backup of each original file.
-B <prefix>, --prefix=<prefix>: Set a prefix for backup files.
-c, --context: Interpret the patch as a context diff.
-d <dir>, --directory=<dir>: Change to the specified directory before starting.
-D <symbol>, --ifdef=<symbol>: Mark changes with #ifdef symbol.
-e, --ed: Interpret the patch as an ed script.
-E, --remove-empty-files: Remove output files that are empty after patching.
-f, --force: Assume the user knows what they are doing and do not ask questions.
-F <lines>, --fuzz=<lines>: Set the maximum fuzz factor (number of lines to ignore when matching).
-i <file>, --input=<file>: Read the patch from the specified file.
-l, --ignore-whitespace: Ignore whitespace differences between the patch and the input.
-n, --normal: Interpret the patch as a normal diff.
-N, --forward: Ignore patches that seem to be already applied or are for older versions.
-o <file>, --output=<file>: Send output to a specified file instead of modifying files in place.
-p <num>, --strip=<num>: Strip num leading components from file paths in the patch.
-r <file>, --reject-file=<file>: Specify the name of the reject file (default is .rej).
-R, --reverse: Assume the patch was created by swapping the new and old files.
-s, --quiet, --silent: Suppress output unless an error occurs.
-u, --unified: Interpret the patch as a unified diff.
-v, --version: Display version information.

Parameters