patch
Apply a unified diff to one or more files. toybox
On Linux
Linux
Apply a unified diff to one or more files. Only handles "unified" diff format (-u is assumed and ignored). Only modifies files when all hunks to that file apply. Prints failed hunks to stderr, and exits with nonzero status if any hunks fail. Files compared against /dev/null (or with a date <= the unix epoch) are created/deleted as appropriate. Default -F value is the number of leading/trailing context lines minus one (usually 2).
patch [-Rlsuv] [-d DIR] [-i FILE] [-p DEPTH] [-F FUZZ] [--dry-run] [FILE [PATCH]]
-d DIRModify files in DIR-F FUZZFuzz factor (number of non-matching context lines allowed per hunk)-i FILEInput patch from FILE (default=stdin)-lLoose match (ignore whitespace)-p DEPTHNumber of '/' to strip from start of file paths (default=all)-RReverse patch-sSilent except for errors-vVerbose (-vv to see decisions)--dry-runDon't change files, just confirm patch appliesSeveral platforms
Patch a file (or files) with a diff file. Note that diff files should be generated by the diff command.
Apply a patch using a diff file (filenames must be included in the diff file)
patch --input patch.diffIdentifyApply a patch to a specific file
patch --input patch.diff path/to/fileIdentifyPatch a file writing the result to a different file
patch --input patch.diff path/to/input_file --output path/to/output_fileIdentifyApply a patch to the current directory
patch --input patch.diff --strip 1IdentifyApply the reverse of a patch
patch --input patch.diff --reverseIdentify