According to wikipedia: A patch is a computer program created to update or correct software in order to improve its usability or performance. When patches fix bugs or security vulnerabilities, it is called a bugfix.
This technique can be used as one of the ways to distribute a software release. It is widely used in computer games in order to update the available content.
The
patch
UNIX command: A patch (Unix) is a computer program on the UNIX operating system that applies the textual differences between two programs and, more often, to computer files containing those differences, or diff files.
According to manual: patch takes a patch file:
patchfile
containing a difference list produced by the diff program and applies those differences to one or more original files, producing versions.
Normally, corrected versions are put in place of the original.
Suppose you have the following file in C++:
vim hello.cpp
And then you create a new one based on it and change a few things:
vim new_hello.cpp
When you run the command diff with the parameter -u
you and generate a patch file: file.patch
:
And then the contents of file.patch
will have the following code:
Although this example is basic and you can change the line manually, in most cases on larger projects it would be a lot of work.
So, to apply the patch, as we saw in its Syntax above, just run the patch
command:
And if you look at the contents of hello.cpp
you will now see that it is identical to that of new_hello.cpp
.
Easy, huh? Of course, there are still a lot of options and it’s worth taking a look at the manual and help:
Just applying a patch.