<?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; tr</title>
	<atom:link href="http://www.wiredrevolution.com/tag/tr/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wiredrevolution.com</link>
	<description>A Bit of Linux Wisdom</description>
	<lastBuildDate>Wed, 18 Jan 2012 22:45:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=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 [...]


Related posts<ol><li><a href='http://www.wiredrevolution.com/system-administration/remove-windows-carriage-returns-with-tr' rel='bookmark' title='Permanent Link: Remove Windows carriage returns with tr'>Remove Windows carriage returns with tr</a></li>
<li><a href='http://www.wiredrevolution.com/commands/convert-pdf-file-to-text-with-pdftotext' rel='bookmark' title='Permanent Link: Convert PDF file to text with pdftotext'>Convert PDF file to text with pdftotext</a></li>
<li><a href='http://www.wiredrevolution.com/bash-programming/convert-a-relative-path-to-absolute-path-in-bash' rel='bookmark' title='Permanent Link: Convert a relative path to absolute path in BASH'>Convert a relative path to absolute path in BASH</a></li>
</ol>]]></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="http://www.wiredrevolution.com/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>Related posts<ol><li><a href='http://www.wiredrevolution.com/system-administration/remove-windows-carriage-returns-with-tr' rel='bookmark' title='Permanent Link: Remove Windows carriage returns with tr'>Remove Windows carriage returns with tr</a></li>
<li><a href='http://www.wiredrevolution.com/commands/convert-pdf-file-to-text-with-pdftotext' rel='bookmark' title='Permanent Link: Convert PDF file to text with pdftotext'>Convert PDF file to text with pdftotext</a></li>
<li><a href='http://www.wiredrevolution.com/bash-programming/convert-a-relative-path-to-absolute-path-in-bash' rel='bookmark' title='Permanent Link: Convert a relative path to absolute path in BASH'>Convert a relative path to absolute path in BASH</a></li>
</ol></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>View process environment details with proc</title>
		<link>http://www.wiredrevolution.com/system-administration/view-process-environment-details-with-proc?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=view-process-environment-details-with-proc</link>
		<comments>http://www.wiredrevolution.com/system-administration/view-process-environment-details-with-proc#comments</comments>
		<pubDate>Wed, 10 Dec 2008 12:42:25 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[system administration]]></category>
		<category><![CDATA[environ]]></category>
		<category><![CDATA[environment variable]]></category>
		<category><![CDATA[PID]]></category>
		<category><![CDATA[proc]]></category>
		<category><![CDATA[tr]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=848</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 process environment consists of all the individual environment variables which are passed on to the program by the shell when the program is launched. This environment can be read and changed by the program during its execution, and can affect how a program is linked or how it executes. For all these reasons it [...]


Related posts<ol><li><a href='http://www.wiredrevolution.com/system-administration/view-system-information-with-proccpuinfo-and-procmeminfo' rel='bookmark' title='Permanent Link: View system information with /proc/cpuinfo and /proc/meminfo'>View system information with /proc/cpuinfo and /proc/meminfo</a></li>
<li><a href='http://www.wiredrevolution.com/bash-programming/find-the-pid-of-a-background-child-process-in-bash' rel='bookmark' title='Permanent Link: Find the PID of a background child process in Bash'>Find the PID of a background child process in Bash</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/how-to-release-the-linux-disk-cache' rel='bookmark' title='Permanent Link: How to release the Linux disk cache'>How to release the Linux disk cache</a></li>
</ol>]]></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 <strong>process environment</strong> consists of all the individual <strong>environment variables</strong> which are passed on to the program by the shell when the program is launched. This environment can be read and changed by the program during its execution, and can affect how a program is linked or how it executes. For all these reasons it may be important at times to see exactly what the environment contains. The <strong>proc</strong> filesystem provides the interface to make this happen.</p>
<p>The <strong>proc</strong> pseudo-file system is used as an interface to kernel data structures.  It is commonly mounted at /proc and most of the files inside are read-only. Within proc there exists a subdirectory for every running process on the system identified by its <strong>process ID</strong> (<strong>PID</strong>). </p>
<p>Inside each process directory is an <strong>environ</strong> file which contains the current environment for that process.</p>
<p><strong>/proc/&lt;PID&gt;/environ</strong></p>
<p>This file is limited at this point in time to 4096 characters. Therefore if you have a process with an unusually large environment the data beyond this limit will be truncated.</p>
<p>The environment variable entries are separated by <strong>null</strong> characters &#8216;<strong>\0</strong>&#8216;, which makes it difficult to view the file.  The best way to get around this is with the <strong>tr</strong> command which will replace the the null characters with <strong>newline</strong> characters &#8216;<strong>\n</strong>&#8216;.</p>
<pre>
$ cat /proc/12345/environ | tr "\000" "\n"
</pre>


<p>Related posts<ol><li><a href='http://www.wiredrevolution.com/system-administration/view-system-information-with-proccpuinfo-and-procmeminfo' rel='bookmark' title='Permanent Link: View system information with /proc/cpuinfo and /proc/meminfo'>View system information with /proc/cpuinfo and /proc/meminfo</a></li>
<li><a href='http://www.wiredrevolution.com/bash-programming/find-the-pid-of-a-background-child-process-in-bash' rel='bookmark' title='Permanent Link: Find the PID of a background child process in Bash'>Find the PID of a background child process in Bash</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/how-to-release-the-linux-disk-cache' rel='bookmark' title='Permanent Link: How to release the Linux disk cache'>How to release the Linux disk cache</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/system-administration/view-process-environment-details-with-proc/feed</wfw:commentRss>
		<slash:comments>0</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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=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 [...]


Related posts<ol><li><a href='http://www.wiredrevolution.com/bash-programming/convert-text-files-within-a-directory-from-windows-to-unix-format' rel='bookmark' title='Permanent Link: Convert text files within a directory from Windows to Unix format'>Convert text files within a directory from Windows to Unix format</a></li>
<li><a href='http://www.wiredrevolution.com/commands/display-the-first-part-of-a-file-with-head' rel='bookmark' title='Permanent Link: Display the first part of a file with head'>Display the first part of a file with head</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/creating-a-windows-boot-disk-with-a-linux-machine' rel='bookmark' title='Permanent Link: Creating a Windows Boot Disk with a Linux Machine'>Creating a Windows Boot Disk with a Linux Machine</a></li>
</ol>]]></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>Related posts<ol><li><a href='http://www.wiredrevolution.com/bash-programming/convert-text-files-within-a-directory-from-windows-to-unix-format' rel='bookmark' title='Permanent Link: Convert text files within a directory from Windows to Unix format'>Convert text files within a directory from Windows to Unix format</a></li>
<li><a href='http://www.wiredrevolution.com/commands/display-the-first-part-of-a-file-with-head' rel='bookmark' title='Permanent Link: Display the first part of a file with head'>Display the first part of a file with head</a></li>
<li><a href='http://www.wiredrevolution.com/system-administration/creating-a-windows-boot-disk-with-a-linux-machine' rel='bookmark' title='Permanent Link: Creating a Windows Boot Disk with a Linux Machine'>Creating a Windows Boot Disk with a Linux Machine</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/system-administration/remove-windows-carriage-returns-with-tr/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

