01 November, 2009

How to use diff and patch in bash script

Diff and patch commands can be used to compare differences of files and change the content based on that. You can see something similar in SVN or wikis.

How to make and use .patch script:

You have to have the original version of file and the edited version of the same file. Then you can make .patch file about the differences with this command:
diff -u /original/file/location /edited/file/location > patch_file_name.patch

You can use the created .patch file on any file with this command:
patch /file/that/will/be/patched < location/of/patch/file.patch

Original Post

No comments:

Post a Comment