Use
Patch file maily used for distributing your software as source code is an excellent idea because it allows a people easily understand how you have implemented things and how you used feature.And also allows people to check and mainly to reuse the source code.Syntax :
patch - apply a diff file to an original
Synopsis:
patch [options] [originalfile [patchfile]]
but usually just
patch -pnum <patchfile
patch : Solves probably only a small percentage of source code has changed between each release.
It was written by Larry Wall, who also written the Perl programming language.
The patch allows you to distribute just the difference between two version
for example this version1 named as file1.c
This is file1
line 2
line 3
there is no line 4, this is line 5
line 6
and then version2 named as file2.c
for example this version1 named as file2.c
This is file2
line 2
line 3
line 4
line 5
line 6
a new line 8
create a difference listing with diff command
$diff file1.c file2.c > diffs
The diff file contains
1c1
< This is file1
---
> This is file2
4c4,5
< there is no line 4, this is line 5
---
> line 4
> line 5
5a7
> a new line 8
you can update your file using patch as follws
$patch file1.c diffs
The patch command has now changed file1.c to be same as file2.c
to unpatch
$Patch -R file1.c diffs
Now the file1.c contains it's original
That's all you need to get started with diff and patch. For more information use:
man diff
man patch
If you like this post Leave the comment here....Thanks
No comments:
Post a Comment