<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Converting Windows And Unix Text Files</title>
	<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/</link>
	<description>Get a grip!</description>
	<pubDate>Fri, 18 May 2012 02:52:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: brrman</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-120793</link>
		<pubDate>Tue, 18 Jan 2011 20:29:41 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-120793</guid>
					<description>Thank you for the Notepad++ tip.  Get app and worked for my Windows -&#62; Unix conversion.</description>
		<content:encoded><![CDATA[<p>Thank you for the Notepad++ tip.  Get app and worked for my Windows -&gt; Unix conversion.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: dc</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-94037</link>
		<pubDate>Tue, 26 May 2009 16:15:06 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-94037</guid>
					<description>I'm trying to write a script that will convert a linux html file into windows format i.e. with (cr)(lf) at the end of each line rather than just a (lf).

I have been trying to use the below script as posted above:

U-&#62;W
perl -pe ’s/\n/\n\r/g’ outfile.txt 

For a start I think it should be:
perl -pe ’s/\n/\r\n/g’ outfile.txt 

But that still doesn't work.

Why is this so difficult?  It seems like a trivial task!!!!

&lt;strong&gt;G:&lt;/strong&gt; It works for me...
perl -pe 's/\n/\r\n/g' inputfile.txt &gt; outputfile.txt

Doing this on a unix system. What are you using?</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to write a script that will convert a linux html file into windows format i.e. with (cr)(lf) at the end of each line rather than just a (lf).</p>
<p>I have been trying to use the below script as posted above:</p>
<p>U-&gt;W<br />
perl -pe ’s/\n/\n\r/g’ outfile.txt </p>
<p>For a start I think it should be:<br />
perl -pe ’s/\n/\r\n/g’ outfile.txt </p>
<p>But that still doesn&#8217;t work.</p>
<p>Why is this so difficult?  It seems like a trivial task!!!!</p>
<p><strong>G:</strong> It works for me&#8230;<br />
perl -pe &#8217;s/\n/\r\n/g&#8217; inputfile.txt > outputfile.txt</p>
<p>Doing this on a unix system. What are you using?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: leorick</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-75821</link>
		<pubDate>Tue, 25 Nov 2008 06:45:50 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-75821</guid>
					<description>Or using Notepad++, under menu "Format" &#62; "Convert to Windows/Unix/MAC"</description>
		<content:encoded><![CDATA[<p>Or using Notepad++, under menu &#8220;Format&#8221; &gt; &#8220;Convert to Windows/Unix/MAC&#8221;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Rajesh</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-48336</link>
		<pubDate>Tue, 13 Nov 2007 08:17:41 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-48336</guid>
					<description>Very useful information. Thanks a lot.

&lt;strong&gt;G:&lt;/strong&gt; Most welcome.</description>
		<content:encoded><![CDATA[<p>Very useful information. Thanks a lot.</p>
<p><strong>G:</strong> Most welcome.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Boredworkers.com &#187; FRREEee&#8230;.ddDDOOM! (IE7, Firefox2.0, Bleach101)</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-13609</link>
		<pubDate>Fri, 03 Nov 2006 10:07:47 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-13609</guid>
					<description>[...] After some issues with Windows/Unix linefeed characters inside one of our demo archives, all the source files are finally checked in to McCabe TRUEchange and I&#8217;m free from the overbearing deadline. Or am I? [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] After some issues with Windows/Unix linefeed characters inside one of our demo archives, all the source files are finally checked in to McCabe TRUEchange and I&#8217;m free from the overbearing deadline. Or am I? [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: gbyeow</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2757</link>
		<pubDate>Wed, 09 Aug 2006 05:21:10 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2757</guid>
					<description>I'm guessing you FTPed it using ASCII and without tarring it first. It won't look so pretty if you did prior to beaming it up.</description>
		<content:encoded><![CDATA[<p>I&#8217;m guessing you FTPed it using ASCII and without tarring it first. It won&#8217;t look so pretty if you did prior to beaming it up.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Simonsays</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2756</link>
		<pubDate>Wed, 09 Aug 2006 02:24:54 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2756</guid>
					<description>Using VBScript, I've typed this in a .vbs file and double-clicked it. I got a sometext_test.txt that I FTP'd using a Cygwin Midnight Commander installation to a RH9 Linux installation. I opened the file in gEdit and vim and the file opened perfectly.

Dim text_test
Set text_test = CreateObject("Scripting.FileSystemObject")
Set text_test_file = text_test.CreateTextFile("sometext_test.txt",True)
text_test_file.WriteLine("This is the first line of text.")
text_test_file.WriteLine("This is the second line of text.")
text_test_file.Close
</description>
		<content:encoded><![CDATA[<p>Using VBScript, I&#8217;ve typed this in a .vbs file and double-clicked it. I got a sometext_test.txt that I FTP&#8217;d using a Cygwin Midnight Commander installation to a RH9 Linux installation. I opened the file in gEdit and vim and the file opened perfectly.</p>
<p>Dim text_test<br />
Set text_test = CreateObject(&#8221;Scripting.FileSystemObject&#8221;)<br />
Set text_test_file = text_test.CreateTextFile(&#8221;sometext_test.txt&#8221;,True)<br />
text_test_file.WriteLine(&#8221;This is the first line of text.&#8221;)<br />
text_test_file.WriteLine(&#8221;This is the second line of text.&#8221;)<br />
text_test_file.Close
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Sooth</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2727</link>
		<pubDate>Mon, 07 Aug 2006 07:44:22 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2727</guid>
					<description>Windows uses linefeeds and carriage returns while unix just uses line feeds.

If you have perl, you can do something like this
W-&#62;U
perl -pe 's/\r//g'  outfile.txt  
U-&#62;W
perl -pe 's/\n/\n\r/g'  outfile.txt</description>
		<content:encoded><![CDATA[<p>Windows uses linefeeds and carriage returns while unix just uses line feeds.</p>
<p>If you have perl, you can do something like this<br />
W-&gt;U<br />
perl -pe &#8217;s/\r//g&#8217;  outfile.txt<br />
U-&gt;W<br />
perl -pe &#8217;s/\n/\n\r/g&#8217;  outfile.txt
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: gbyeow</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2660</link>
		<pubDate>Tue, 01 Aug 2006 05:18:02 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2660</guid>
					<description>Hi ttc,

When it comes to text files, most languages adhere to a WYWIWYG approach. What You Write Is What You Get. VB similarly follows the same rule and will not append any new characters to the end of the file when it closes it. The only exception to this rule is when you a built in function which automatically appends a newline character when it is done. The newline character that is used is OS dependant.

Doing something of this form will give you the result you desire:

&lt;code&gt;Dim fs As New FileStream("c:\somefile.txt", FileMode.Append, FileAccess.Write, FileShare.Write)
fs.Close()
Dim sw As New StreamWriter("c:\somefile.txt", True, Encoding.ASCII)
Dim somestring As String
somestring = "Line 1." &#38; vbLf
sw.Write(somestring)
somestring = "Line 2" &#38; vbLf
sw.Write(somestring)
sw.Close()&lt;/code&gt;

The text file will come out with the linefeed character at the end of each line. VB does not automatically add the ^M character when it closes the file (unless as I mentioned earlier, you're using one of those built in functions that does so). Transporting it to Unix will give you the correct readable text format.

Hope this helps and good luck.</description>
		<content:encoded><![CDATA[<p>Hi ttc,</p>
<p>When it comes to text files, most languages adhere to a WYWIWYG approach. What You Write Is What You Get. VB similarly follows the same rule and will not append any new characters to the end of the file when it closes it. The only exception to this rule is when you a built in function which automatically appends a newline character when it is done. The newline character that is used is OS dependant.</p>
<p>Doing something of this form will give you the result you desire:</p>
<p><code>Dim fs As New FileStream("c:\somefile.txt", FileMode.Append, FileAccess.Write, FileShare.Write)<br />
fs.Close()<br />
Dim sw As New StreamWriter("c:\somefile.txt", True, Encoding.ASCII)<br />
Dim somestring As String<br />
somestring = "Line 1." &amp; vbLf<br />
sw.Write(somestring)<br />
somestring = "Line 2" &amp; vbLf<br />
sw.Write(somestring)<br />
sw.Close()</code></p>
<p>The text file will come out with the linefeed character at the end of each line. VB does not automatically add the ^M character when it closes the file (unless as I mentioned earlier, you&#8217;re using one of those built in functions that does so). Transporting it to Unix will give you the correct readable text format.</p>
<p>Hope this helps and good luck.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: tcc</title>
		<link>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2658</link>
		<pubDate>Tue, 01 Aug 2006 01:34:56 +0000</pubDate>
		<guid>http://www.boredworkers.com/2006/07/27/converting-windows-and-unix-text-files/#comment-2658</guid>
					<description>I've read almost every post on the web about the line termination issue, but I haven't found the answer to the following variation:

I am putting together text files in Windows (I happen to be outputting using VB), and these files need to be transferred to a Unix box.  I need to make them Unix-ready BEFORE I send them (they're being FTP'ed in a TAR file in binary mode along with some other things).

So how do I rip out all of the Ctrl-M/Chr(13)'s before I send the text file?  I thought about just writing out the file as a block of text with Chr(10) inserted where I want a line feed in Unix, but I'm concerned that I'll still end up with a Ctrl-M at the end resulting when VB closes the file.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve read almost every post on the web about the line termination issue, but I haven&#8217;t found the answer to the following variation:</p>
<p>I am putting together text files in Windows (I happen to be outputting using VB), and these files need to be transferred to a Unix box.  I need to make them Unix-ready BEFORE I send them (they&#8217;re being FTP&#8217;ed in a TAR file in binary mode along with some other things).</p>
<p>So how do I rip out all of the Ctrl-M/Chr(13)&#8217;s before I send the text file?  I thought about just writing out the file as a block of text with Chr(10) inserted where I want a line feed in Unix, but I&#8217;m concerned that I&#8217;ll still end up with a Ctrl-M at the end resulting when VB closes the file.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>

