{"id":48,"date":"2014-02-10T00:24:00","date_gmt":"2014-02-10T00:24:00","guid":{"rendered":"http:\/\/371@jodohost.com\/\/blog\/"},"modified":"2014-02-10T00:24:00","modified_gmt":"2014-02-10T00:24:00","slug":"how-to-use-diff-and-patch","status":"publish","type":"post","link":"http:\/\/www.jodohost.com\/blog\/index.php\/2014\/02\/10\/how-to-use-diff-and-patch\/","title":{"rendered":"How to use diff and patch"},"content":{"rendered":"<p>We&#8217;ll learn the three things below, as follows:- <\/p>\n<p>1) Differentiating between two files and redirecting the differences into a new file.<br \/>2) Creating a patch file with the diff command utility.<br \/>3) Updating the file with patch.<\/p>\n<p>diff => diff is a Unix utility showing the difference between two files which are almost similiar by virtue of their contents.<\/p>\n<p>patch => patch is a Unix utility which is used for applying the differences between two files to make them similiar or the same by virtue of their contents.<\/p>\n<p>1) With the diff command utiliy we can show the difference between two files on the screen or can also redirect them into a file which will create a patch for making the target file the same as the source file.<\/p>\n<p>i) To get the output on the screen between two files, use the command:- <\/p>\n<p>diff abc_file.txt xyz_file.txt<\/p>\n<p>ii) To redirect the difference between two files into one file, use the command below:- <\/p>\n<p>diff abc_file.txt xyz_file.txt\u00a0 > diff_file.txt<\/p>\n<p>2) Now, creating a patch file with the diff command utility is as below:- <\/p>\n<p>diff -uN orig_file new_file > patch.orig_file<\/p>\n<p>3) Applying the file with patch<\/p>\n<p>patch -u new_file patch.orig_file<\/p>\n<p>and then when you check new_file, it&#8217;ll have all the changes done and it&#8217;ll have the same contents as orig_file.txt.<\/p>\n<p>Using and applying a patch is the quickest way to do many changes with just one command, when you need to change multiple files for the same changes. That&#8217;s all.<\/p>\n<p> ]]><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ll learn the three things below, as follows:- 1) Differentiating between two files and redirecting the differences into a new file.2) Creating a patch file with the diff command utility.3) Updating the file with patch. diff => diff is a Unix utility showing the difference between two files which are almost similiar by virtue of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/48"}],"collection":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":0,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}