<?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>WiredRevolution.com &#187; CRLF</title>
	<atom:link href="http://www.wiredrevolution.com/tag/crlf/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wiredrevolution.com</link>
	<description>A Bit of Linux Wisdom</description>
	<lastBuildDate>Sat, 22 May 2010 16:03:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Convert text files within a directory from Windows to Unix format</title>
		<link>http://www.wiredrevolution.com/bash-programming/convert-text-files-within-a-directory-from-windows-to-unix-format</link>
		<comments>http://www.wiredrevolution.com/bash-programming/convert-text-files-within-a-directory-from-windows-to-unix-format#comments</comments>
		<pubDate>Wed, 07 Jan 2009 14:14:33 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[carriage return]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[CRLF]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[tr]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=901</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/bash_icon.png" width="80" height="34" alt="" title="bash" /><br/>When a file is saved in Windows and then moved to a Linux system the formatting differences can cause a variety of problems. To effectively use these files you will need to change the format from Windows/DOS to Unix. This conversion occurs by simply removing the Windows carriage return characters.
I have explained how to use [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/bash_icon.png" width="80" height="34" alt="" title="bash" /><br/><p>When a file is saved in Windows and then moved to a Linux system the formatting differences can cause a variety of problems. To effectively use these files you will need to change the format from Windows/DOS to Unix. This conversion occurs by simply removing the Windows carriage return characters.</p>
<p>I have explained how to <a href="/system-administration/remove-windows-carriage-returns-with-tr">use the tr command remove these windows carriage returns</a>, but when you have a large amount of files to convert this can become tedious. As a solution to this I have written a BASH script to convert all text files within a directory.</p>
<pre>
#!/bin/bash

for file in /directory/to/convert/*
do
  if [[ -f $file &#038;&#038; `file $file | grep text` ]]
  then
    tr -d '\r' < $file > "$file"_clear
    mv "$file"_clear $file
  fi
done
</pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/bash-programming/convert-text-files-within-a-directory-from-windows-to-unix-format/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Remove Windows carriage returns with tr</title>
		<link>http://www.wiredrevolution.com/system-administration/remove-windows-carriage-returns-with-tr</link>
		<comments>http://www.wiredrevolution.com/system-administration/remove-windows-carriage-returns-with-tr#comments</comments>
		<pubDate>Sun, 30 Nov 2008 15:46:17 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[ASCII]]></category>
		<category><![CDATA[carriage return]]></category>
		<category><![CDATA[CRLF]]></category>
		<category><![CDATA[dos2unix]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[tr]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=794</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/sysadmin_icon.png" width="80" height="94" alt="" title="system administration" /><br/>The end of a line in a UNIX text file is designated with the newline character. In Windows, a line ends with both newline and carriage return ASCII characters. If a file is saved in Windows and then moved to a Linux system these carriage returns can cause all sorts of problems. If the text [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/sysadmin_icon.png" width="80" height="94" alt="" title="system administration" /><br/><p>The end of a line in a UNIX text file is designated with the newline character. In Windows, a line ends with both newline and carriage return ASCII characters. If a file is saved in Windows and then moved to a Linux system these carriage returns can cause all sorts of problems. If the text file is a BASH script for example it will not run correctly since it doesn&#8217;t know how to interpret these characters.</p>
<p>You can verify that a text file has these Windows carriage returns by running the <strong>cat</strong> command with the <strong>&#8216;-v</strong>&#8216; option which shows the non-printing characters.</p>
<pre>
$ cat -v inputfile | head
</pre>
<pre>
first line^M
second line^M
</pre>
<p>You can see the carriage return characters, &#8220;<strong>^M</strong>&#8221; (Cntl-M). </p>
<p>CRLF = Carriage Return Line Feed</p>
<p>There are various was to remove these carriage returns. You can use the <strong>dos2unix</strong> command but this is rarely installed by default on a a Linux system. The easiest way then is to use the &#8220;<strong>tr</strong>&#8221; command utility which always comes standard.</p>
<p>The command uses the <strong>tr</strong> command which translates and removes characters. This will remove the carriage return characters.</p>
<pre>
$ tr -d '\r' < inputfile > outputfile
</pre>
<p>You can verify they are really gone by running the same cat command again.</p>
<pre>
$ cat -v outputfile | head
</pre>
<pre>
first line
second line
</pre>
<p>You can also run the file command.</p>
<pre>
$ file inputfile
</pre>
<pre>
inputfile:             ASCII text
</pre>
<p>Optionally you can now overwrite the original file.</p>
<pre>
$ mv outputfile inputfile
</pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/system-administration/remove-windows-carriage-returns-with-tr/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
