Wednesday, May 13, 2009

Kill BUG using patch

so, finally i know that how to create a patch :D,this is a beautiful concept to remove a bug by using simple Linux commands . The command 'diff' and 'patch' create a powerful combination and hit the bug from the program :) ,diff command is widely used to get a difference between original file and updated file and this difference is stored in a patch file and through this way other people who have only a original file can change it in to a update file by applying a patch using a patch file.

create  a patch

we create a patch by using diff command , suppose we have to file 'original' and 'updated' the content of original file is "my name is aman" and the content of updated file is "my name is neshu",and we have to conver the original file in to the updated file by applying a patch and patch would be created as,

$>diff original updated > patchfile.patch 

now patchfile.patch conatin a difference of both files

$>cat patchfile.patch

1c1
<
my name is aman

---

>my name is neshu

1c1 denotes that there is some thing to  change at 1st line
similarly 'd' is for delete and 'a' is for add

As you may have noticed, I omitted explaining what the 3 -'s are for. They indicate the end of the lines that should be replaced and the beginning of the lines that should replace them. They separate the old and the new lines.

Applying a patch

Applying a patch is a very simple task , after applying a patch on original file it will convert it in to updated file ,

$>patch original patchfile.patch

patching file original

 original file is now converted in to updated  

--

Happy Patching :)

:-fat0ss