TrumanWong

patch

Install patches for open source software

Supplementary instructions

patch command is used to install patches for open source software. Allow users to modify and update original files by setting patch files. If you only modify one file at a time, you can directly issue commands in the command line and execute them sequentially. If you cooperate with the method of patching files, you can patch a large number of files at one time. This is also one of the core upgrade methods of Linux systems.

grammar

patch(option)(parameter)

Options

-b or --backup: Back up each original file;
-B<backup prefix string> or --prefix=<backup prefix string>: When setting file backup, the prefix string appended in front of the file name, this string can be a path name;
-c or --context: Interpret patch data into correlation differences;
-d<working directory> or --directory=<working directory>: Set the working directory;
-D <marker> or --ifdef=<marker>: Use the specified symbol to mark the changed place;
-e or --ed: interpret the patch data into a narrative file that can be used by the ed command;
-E or --remove-empty-files: If the content of the output file after patching is blank, remove the file;
-f or --force: The effect of this parameter is similar to specifying the "-t" parameter, but it will be assumed that the version of the patched data is a new version;
-F <number of monitoring columns> or --fuzz <number of monitoring columns>: Set the maximum value of the number of monitoring columns;
-g<control value> or --get=<control value>: Set to control the patching operation with RSC or SCCS;
-i<patch file> or --input=<patch file>: Read the specified patch file;
-l or --ignore-whitespace: Ignore tabs and space characters in patch data and input data;
-n or --normal: interpret patch data into general differences;
-N or --forward: Ignore that the patched data is older than the original file version, or the patched data of this version has been used;
-o<output file> or --output=<output file>: Set the name of the output file, and the patched file will be stored under this name;
-p<Strip Level> or --strip=<Strip Level>: Set the path names of several layers to be stripped;
-f <reject file> or --reject-file=<reject file>: Set the file name to save rejection patch related information. The default file name is .rej;
-R or --reverse: Assume that the patch data is generated by exchanging the positions of the old and new files;
-s or --quiet or --silent: Do not display the instruction execution process unless an error occurs;
-t or --batch: automatically skip errors and do not ask any questions;
-T or --set-time: The effect of this parameter is similar to specifying the "-Z" parameter, but it is based on local time;
-u or --unified: interpret patch data into unified differences;
-v or --version: display version information;
-V<backup method> or --version-control=<backup method>: After backing up the target file with the "-b" parameter, a backup string will be added to the end of the backup file. This string is not only available "- z" parameter change, when using the "-V" parameter to specify different backup methods, backup strings with different suffixes will also be generated;
-Y<backup prefix string> or --basename-prefix=--<backup prefix string>: When setting file backup, append the prefix string to the beginning of the file base name;
-z<backup suffix string> or --suffix=<backup suffix string>: The effect of this parameter is similar to specifying the "-B" parameter. The difference is that the path and file name used in the patch job are src/linux /fs/super.c, after adding the "backup/" string, the file super.c will be backed up in the /src/linux/fs/backup directory;
-Z or --set-utc: Change the patched file and set the access time to UTC;
--backup-if-mismatch: Backup the file only when the patched data does not completely match and the file is not deliberately specified to be backed up;
--binary: Read and write data in binary mode without passing the standard output device;
--help: online help;
--nobackup-if-mismatch: Do not back up the file when the patched data does not completely match and the file is not specifically specified to be backed up;
--verbose: Display the execution process of the command in detail.

Parameters

  • Original file: Specify the original file that needs to be patched;
  • Patch file: Specify the patch file.