How To Create and Apply a Patch File Using the diff and patch Commands
erics, Posted January 25th, 2016 at 4:18:04pm
Create the patch by using the diff -u
command:
1 2 3 4 5 |
~ $ diff -u myfile myfile.modified > myfile.patch ~ $ ls myfile myfile.modified myfile.patch |
To use the patch file, apply it to the original. The patch command will create a backup with the extension .orig, and the original file will be updated:
1 2 3 4 5 6 |
~ $ patch -b myfile < myfile.patch ~ $ ls myfile myfile.modified myfile.orig myfile.patch |
You may need to add the flag --ignore-whitespace
to the patch command.
Leave Your Comment
All fields marked with "*" are required.