{"id":44,"date":"2020-06-21T21:21:03","date_gmt":"2020-06-21T21:21:03","guid":{"rendered":"http:\/\/pipeawk.com\/?p=44"},"modified":"2025-12-11T14:55:17","modified_gmt":"2025-12-11T14:55:17","slug":"unix-vs-windows-end-of-line-mystery","status":"publish","type":"post","link":"https:\/\/pipeawk.com\/index.php\/2020\/06\/21\/unix-vs-windows-end-of-line-mystery\/","title":{"rendered":"UNIX vs. Windows End-of-Line Mystery"},"content":{"rendered":"<p>Time to discuss the infamous <strong>end-of-line<\/strong> in <strong>UNIX<\/strong> like systems vs. <strong>Windows<\/strong> systems. Just in case you do not know what\u00a0<strong>end-of-line<\/strong> is. End of line character is the character that tells the system that the line of the file ends. For example, when you write a text file using a text editor, you may write something like:<\/p>\n<blockquote><p>This is the first line of the text file<br \/>\nThis is the second line of the text file<\/p><\/blockquote>\n<p>When editing the file, to indicate to the system that the line is finished, you would press the &#8216;Enter&#8217; key.<!--more--><\/p>\n<p>Now, if you always edit files in UNIX and remain in UNIX, no problems will be ever noted. If always editing on Windows, again, no problems will be ever noted.<\/p>\n<p>The issue presents itself should you edit a file in UNIX and want to view it in Windows and vice-versa.<\/p>\n<p>Let&#8217;s say that you created the above file on a UNIX system, then in Windows, using notepad, you open the file, you will see:<\/p>\n<blockquote><p>This is the first line of the text fileThis is the second line of the text file<\/p><\/blockquote>\n<p>As you see, everything is on one single line. Should you do the opposite, editing the file in Windows, then open it in UNIX, you will see something like:<\/p>\n<blockquote><p>This is the first line of the text file^M<br \/>\nThis is the second line of the text file^M<\/p><\/blockquote>\n<p>Now, let&#8217;s explain why there is such a difference.<\/p>\n<p>In UNIX the end of line character is the new-line or line-feed character, it is represented different ways: \\n, ASCII(10), LF, etc.<\/p>\n<p>In Windows the end of line is represented by 2 characters, line-feed and carriage-return. Carriage return is represented in different ways also: \\r, ASCII(13), CR, etc.<\/p>\n<p>To summarize, in UNIX the end of line is <strong>\\n<\/strong>, in Windows the end of line is <strong>\\r\\n<\/strong>.<\/p>\n<p>Modern file transfer applications can automatically resolve the problem for you. For example, in FTP or SFTP you can setup the application to automatically correct the end-of-line characters based on the destination platform. Also some modern text editors automatically understand the end of line.<\/p>\n<p>I hope this clears the problem some, but in order to really understand, please experiment in dealing with files on UNIX and Windows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Time to discuss the infamous end-of-line in UNIX like systems vs. Windows systems. Just in case you do not know what\u00a0end-of-line is. End of line character is the character that tells the system that the line of the file ends. For example, when you write a text file using a text editor, you may write &hellip; <a href=\"https:\/\/pipeawk.com\/index.php\/2020\/06\/21\/unix-vs-windows-end-of-line-mystery\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;UNIX vs. Windows End-of-Line Mystery&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-unix"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":9,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":365,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/posts\/44\/revisions\/365"}],"wp:attachment":[{"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pipeawk.com\/index.php\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}