{"id":317,"date":"2020-05-20T05:11:00","date_gmt":"2020-05-20T05:11:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=317"},"modified":"2020-12-17T05:13:20","modified_gmt":"2020-12-17T05:13:20","slug":"comparing-files-using-diff-and-cmp","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/comparing-files-using-diff-and-cmp\/","title":{"rendered":"Comparing files using diff and cmp"},"content":{"rendered":"\n<p>The diff command gives details of differences between two files. The cmp command simply tells you whether two files are the same or different.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ diff one.txt two.txt<\/code><\/pre>\n\n\n\n<p>The results would be something like the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>14c14\n&lt; txt txt txt\n---\n> text text text<\/code><\/pre>\n\n\n\n<p>The first line indicates the line number(s) which are different between files. The letter c indicates that line 14 must be changed for them to match. The &lt; symbol refers to the text in the first file. &gt; symbol refers to the second file.<\/p>\n\n\n\n<p>The cmp command simply gives a yes|no answer. Ideal for comparing binary files. If the files are identical, no result is printed. If the files differ, the filename and the byte where the first difference is encountered is returned.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cmp one.txt two.txt<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The diff command gives details of differences between two files. The cmp command simply tells you whether two files are the same or different. The results would be something like the following: The first line indicates the line number(s) which are different between files. The letter c indicates that line 14 must be changed for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[122,121,35],"class_list":["post-317","post","type-post","status-publish","format-standard","hentry","category-linux","tag-cmp","tag-diff","tag-linux"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=317"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/317\/revisions"}],"predecessor-version":[{"id":318,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/317\/revisions\/318"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}