<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nikola.paunovski</title>
	<atom:link href="http://nikola.paunovski.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://nikola.paunovski.net</link>
	<description></description>
	<lastBuildDate>Thu, 09 Feb 2012 19:38:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Remove ^M from unix files</title>
		<link>http://nikola.paunovski.net/remove-m-from-unix-files/</link>
		<comments>http://nikola.paunovski.net/remove-m-from-unix-files/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 19:36:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://nikola.paunovski.net/?p=148</guid>
		<description><![CDATA[^M - these usually occur when uploading files from a windows system, using ascii mode.  Some Windows editors may add the character to the end of each line as well during editing. <a href="http://nikola.paunovski.net/remove-m-from-unix-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>^M &#8211; these usually occur when uploading files from a windows system, using ascii mode.  Some Windows editors may add the character to the end of each line as well during editing.</p>
<p>Sometimes, it&#8217;s hard to even find them.  One pretty foolproof way on a Linux / Unix system is to use cat:<br />
<code><br />
cat -e [filename]<br />
</code><br />
This will show you lines with a $ at the end, and ^M&#8217;s should show up, if they are there.  Here are a few options to remove them:</p>
<h1>Method 1:</h1>
<p>In the vi editor, do the following:<br />
<code><br />
:.,$s/(ctrl-v)(ctrl-m)//g (enter)<br />
</code><br />
After typing the (ctrl-v)(ctrl-m) combination, you should see a &#8220;^M&#8221; in the line (note, the ^M is NOT just a &#8216;^&#8217; and an &#8216;M&#8217;, it&#8217;s a special control character. If you try to reproduce it without the control sequence I describe here, you&#8217;ll really mess up your file.</p>
<p>If you do screw something up, just type:<br />
<code><br />
:q!<br />
</code><br />
which will exit the editor without saving, and you can start fresh and try again.</p>
<h1>Method 2: Using sed</h1>
<p>From your Linux shell prompt, do the following:<br />
<code><br />
sed -e 's/(cntrl-v)(cntrl-m)//g' [filename] > [new filename]<br />
</code><br />
This creates a new file with the ^M&#8217;s removed</p>
<h1>Method 3:</h1>
<p>If your system has the &#8216;dos2unix&#8217; utility, you can do this:<br />
<code><br />
dos2unix [filename]<br />
</code></p>
<p>This has the advantage of replacing the original file, so you don&#8217;t need to move anything after running this command.</p>
]]></content:encoded>
			<wfw:commentRss>http://nikola.paunovski.net/remove-m-from-unix-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

