info > patch(1)

πŸ”§ 15 Invoking β€˜patch’

πŸ“˜ Normally β€˜patch’ is invoked like this:

patch <PATCHFILE

πŸ“‹ The full format for invoking β€˜patch’ is:

patch OPTIONS... [ORIGFILE [PATCHFILE]]

πŸ“Œ You can also specify where to read the patch from with the -i PATCHFILE or --input=PATCHFILE option. If you do not specify PATCHFILE, or if PATCHFILE is β€˜-’, β€˜patch’ reads the patch (that is, the β€˜diff’ output) from the standard input.

πŸ“Œ If you do not specify an input file on the command line, β€˜patch’ tries to intuit from the β€œleading text” (any text in the patch that comes before the β€˜diff’ output) which file to edit. πŸ“– Multiple Patches.

πŸ“Œ By default, β€˜patch’ replaces the original input file with the patched version, possibly after renaming the original file into a backup file. πŸ’Ύ Backup Names describes how β€˜patch’ names backup files. You can also specify where to put the output with the -o FILE or --output=FILE option; however, do not use this option if FILE is one of the input files.

πŸš€ Quick Reference

Use CaseCommandDescription
Apply a patch from a filepatch < patchfileRead patch from standard input or file with -i
Apply patch with backuppatch -b < patchfileBack up original files before applying
Dry run (test without changes)patch --dry-run < patchfileShow results without modifying files
Reverse a patchpatch -R < patchfileAssume old/new files swapped, undo a patch
Apply patch with fuzz factorpatch -F 3 < patchfileAllow up to 3 lines of fuzz for inexact matches
Strip leading directoriespatch -p1 < patchfileStrip first component of file paths
Output to specific filepatch -o outputfile < patchfileWrite patched output to a file instead of in-place

πŸ“‹ 15.1 Options to β€˜patch’

Here is a summary of all of the options that GNU β€˜patch’ accepts. πŸ“– patch and Tradition for which of these options are safe to use in older versions of β€˜patch’.

πŸ”— Multiple single-letter options that do not take an argument can be combined into a single command line argument with only one dash.

patch(1)
πŸ”§ 15 Invoking β€˜patch’ πŸš€ Quick Reference
πŸ“‹ 15.1 Options to β€˜patch’

Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-20 19:38 @216.73.216.26
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^