<?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>words &#187; Scripting</title>
	<atom:link href="http://www.curlybrace.com/words/category/technology/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.curlybrace.com/words</link>
	<description>by Jeff Fitzsimons</description>
	<lastBuildDate>Tue, 20 Dec 2011 10:21:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Alternate Data Streams (Metadata) on Files in NTFS</title>
		<link>http://www.curlybrace.com/words/2011/01/01/alternate-data-streams/</link>
		<comments>http://www.curlybrace.com/words/2011/01/01/alternate-data-streams/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 07:51:50 +0000</pubDate>
		<dc:creator>Jeff Fitzsimons</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.curlybrace.com/words/?p=1120</guid>
		<description><![CDATA[Introduction Alternate Data Streams (ADS) allow arbitrary metadata to be associated with files and directories on Windows NTFS. Alternate data streams are the Windows implementation of forks. The apparent size of the file will be unchanged, and most applications and &#8230; <a href="http://www.curlybrace.com/words/2011/01/01/alternate-data-streams/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Alternate Data Streams (ADS) allow arbitrary metadata to be associated with files and directories on Windows NTFS.  Alternate data streams are the Windows implementation of <a href="http://en.wikipedia.org/wiki/Fork_%28filesystem%29">forks</a>.  The apparent size of the file will be unchanged, and most applications and users are unaware of their existence.  If a file is moved, any alternate data stream will move along with it, as long as the destination is on an NTFS drive.</p>
<p>The command line can access alternate data streams using redirection operators.  Streams are specified on the command line as <i>filename</i><b>:</b><i>stream name</i>.</p>
<h3>Creating an Alternate Data Stream</h3>
<p>As an example, a string is written into an ADS named <tt>hidden</tt>, which is associated with file <tt>test.txt</tt>:</p>
<blockquote><pre class="DOS">C:\test>echo Hidden text > test.txt:hidden</pre>
</blockquote>
<p>The file appears to be empty, though as detailed below, the metadata is intact and associated with the file:</p>
<blockquote><pre class="DOS">C:\test>dir test.txt

06/24/2010  01:33 PM                 0 test.txt</pre>
</blockquote>
<h3>Viewing an Alternate Data Stream</h3>
<p>The metadata can be viewed by redirecting from it to <tt>more</tt>:</p>
<blockquote><pre class="DOS">C:\test>more < test.txt:hidden
Hidden text</pre>
</blockquote>
<p>The name and content of the ADS can be anything (see 'Details' below for restrictions):</p>
<blockquote><pre class="DOS">C:\test>echo Arbitrary string > test.txt:arbitraryName

C:\test>more < test.txt:arbitraryName
Arbitrary string</pre>
</blockquote>
<h3>Listing Files With Alternate Data Streams</h3>
<p>On Windows Vista and later, a list of alternate data streams can be obtained using <tt>DIR /R</tt>:</p>
<blockquote><pre class="DOS">C:\test>dir test.txt /R

06/24/2010  01:33 PM                 0 test.txt
                                    38 test.txt:arbitraryName:$DATA
                                    28 test.txt:hidden:$DATA</pre>
</blockquote>
<p>On earlier operating systems, the SysInternals utility <a href="http://technet.microsoft.com/en-us/sysinternals/bb897440">Streams</a> can be used:</p>
<blockquote><pre class="DOS">C:\test>c:\tools\SysInternals\streams.exe test.txt

Streams v1.56 - Enumerate alternate NTFS data streams
Copyright (C) 1999-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\test\test.txt:
   :arbitraryName:$DATA 38
          :hidden:$DATA 28</pre>
</blockquote>
<h3>Alternate Data Streams on Directories</h3>
<p>Metadata can be added to directories the same way it's added to files:</p>
<blockquote><pre class="DOS">C:\test>mkdir test2

C:\test>echo ADS on a directory > test2:someText

C:\test>dir /r

06/25/2010  11:27 PM    &lt;DIR&gt;          .
06/25/2010  11:27 PM    &lt;DIR&gt;          ..
06/25/2010  11:27 PM    &lt;DIR&gt;          test2
                                    42 test2:someText:$DATA

C:\test>more < test2:someText
ADS on a directory</pre>
</blockquote>
<h2>Details</h2>
<h3>Stream Naming</h3>
<p>To be more accurate, streams are specified as <i>filename</i><b>:</b><i>stream name</i><b>:</b><i>stream type</i>.  It appears that the only stream type accessible from the command line is $DATA, which is why it's optional.  All of the stream types are listed in the <a href="http://msdn.microsoft.com/en-us/library/aa362667%28v=VS.85%29.aspx">WIN32_STREAM_ID structure documentation</a>.  The default data stream is unnamed, so <i>filename</i>::$DATA will contain the file's data:</p>
<blockquote><pre class="DOS">C:\test>echo This is the file > file.txt

C:\test>echo This is the stream > file.txt:stream

C:\test>more < file.txt::$DATA
This is the file

C:\test>more < file.txt:stream:$DATA
This is the stream</pre>
</blockquote>
<p>Stream names are generally held to the same requirements as any filename.  One interesting difference is that stream names can contain characters whose integer representations are in the range from 1 through 31.  Refer to <a href="http://msdn.microsoft.com/en-us/library/aa365247%28v=VS.85%29.aspx">Naming Files, Paths, and Namespaces</a> (MSDN) for details.</p>
<p>Note that when using streams with files having a single letter name, the filename should be prefixed with a period and backslash.  The reason for this is Windows drive names.  For example, does "<tt>echo hello > c:test</tt>" refer to a stream named <tt>test</tt> on file <tt>c</tt>, or does it refer to a file <tt>test</tt> on drive <tt>c</tt>?</p>
<h3>Executing Streams</h3>
<p>As of Windows Vista, it is no longer possible to execute directly from an alternate data stream.  On Windows XP and earlier, the Start command was used, similar to <tt>start somefile.ext:hiddenExecutable</tt>.</p>
<h3>Editing with Notepad</h3>
<p>Notepad can be used to create and edit alternate data streams.  The File Open dialog doesn't recognize stream syntax, however, so the file must be created and opened using command line parameters.  Notepad will insist on appending <tt>.txt</tt> to the stream name.</p>
<h3>Programmatic Access</h3>
<p>Microsoft provides a <a href="http://support.microsoft.com/kb/105763">sample program</a> in C++, demonstrating how to open and write to an alternate data stream.</p>
<h2>Real-World Applications</h2>
<h3>Downloaded Executables</h3>
<p><a href="http://blogs.msdn.com/b/oldnewthing/archive/2007/08/27/4580767.aspx?PageIndex=4">Since Windows XP SP2</a>, when a file is downloaded from the Internet and executed (assuming a zone-aware browser), this warning is displayed:</p>
<blockquote><p><a href="http://www.curlybrace.com/words/wp-content/uploads/2010/06/UAC_Example_s.png"><img src="http://www.curlybrace.com/words/wp-content/uploads/2010/06/UAC_Example_s.png" alt="" title="UAC_Example_s" width="320" height="192" class="aligncenter size-full wp-image-1127" /></a></p></blockquote>
<p>Windows displays this warning because the web browser tagged the executable with a alternate data stream named <tt>Zone.Identifier</tt>:</p>
<blockquote><pre class="DOS">C:\test>dir /r setup.exe

06/25/2010  12:10 PM           680,467 setup.exe
                                    26 setup.exe:Zone.Identifier:$DATA</pre>
</blockquote>
<p>By redirecting this stream to <tt>more</tt>, we can see its contents:</p>
<blockquote><pre class="DOS">C:\test>more < setup.exe:Zone.Identifier
[ZoneTransfer]
ZoneId=3</pre>
</blockquote>
<p>The <a href="http://blogs.msdn.com/b/powershell/archive/2007/03/07/how-does-the-remotesigned-execution-policy-work.aspx">PowerShell blog</a> has more information on zone identifiers.</p>
<h3>Viruses</h3>
<p>The W2K.Stream virus <a href="http://www.symantec.com/security_response/writeup.jsp?docid=2000-121416-2928-99">used alternate data streams</a>.</p>
<h2>Additional Resources</h2>
<ul>
<li /><a href="http://msdn.microsoft.com/en-us/library/ms810604.aspx"><del>A Programmer's Perspective on NTFS 2000 Part 1: Stream and Hard Link</del></a> (MSDN, article removed)
<li /><a href="http://msdn.microsoft.com/en-us/library/ms810500.aspx"><del>A Programmer's Perspective on NTFS 2000 Part 2: Encryption, Sparseness, and Reparse Points</del></a> (MSDN, article removed)
<li /><a href="http://msdn.microsoft.com/en-us/library/aa364404%28v=VS.85%29.aspx">File Streams</a> (MSDN)
<li /><a href="http://www.codeproject.com/KB/shell/csadsdetectorarticle.aspx">Visual browsing of alternative data-streams in Windows Explorer</a> (CodeProject)
<li /><a href="http://www.alex-ionescu.com/NTFS%20Alternate%20Data%20Streams.pdf">NTFS Alternate Data Streams</a> (Alex Ionescu)
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.curlybrace.com/words/2011/01/01/alternate-data-streams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting MP3 to AAC</title>
		<link>http://www.curlybrace.com/words/2010/02/05/converting-mp3-to-aac/</link>
		<comments>http://www.curlybrace.com/words/2010/02/05/converting-mp3-to-aac/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 07:27:21 +0000</pubDate>
		<dc:creator>Jeff Fitzsimons</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.curlybrace.com/words/?p=895</guid>
		<description><![CDATA[Here is a Windows command shell script I wrote to convert MP3 files to AAC for my Softbank 821SC phone. The script uses FFmpeg, which I downloaded from here. @echo off REM --------------------------------------------------------------------------- REM Set the following variable to the &#8230; <a href="http://www.curlybrace.com/words/2010/02/05/converting-mp3-to-aac/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is a Windows command shell script I wrote to convert MP3 files to AAC for my Softbank 821SC phone.  The script uses FFmpeg, which I downloaded from <a href="http://ffmpeg.arrozcru.org/autobuilds/">here</a>.</p>
<blockquote>
<pre class="DOS">
@echo off

REM ---------------------------------------------------------------------------
REM  Set the following variable to the ffmpeg.exe path on your system.
REM ---------------------------------------------------------------------------
set FFMPEG_PATH="c:\tools\FFmpeg\ffmpeg.exe"

REM make sure the user provided an argument.
if NOT "%~1" == "" goto ARGS_OK

REM bad arguments, print error and exit.
echo.
echo    Usage examples:
echo       mp3toaac.bat file_to_convert.mp3
echo       mp3toaac.bat *.mp3
echo       mp3toaac.bat some_directory\*.mp3
exit /b 1

:ARGS_OK

REM use for/in so that we can accept individual files or wildcards.
for %%i in ("%~1") do %FFMPEG_PATH% -i "%%~i" "%%~ni.aac"

echo.
echo Done.

exit /b 0
</pre>
</blockquote>
<p>Interesting elements of this batch file:</p>
<ul>
<li />Use of <tt>for</tt>/<tt>in</tt> in order to accept both filenames and wildcards.
<li />Use of <tt>%~<i>X</i></tt> to strip parentheses from a filename variable.
<li />Use of <tt>%~n<i>X</i></tt> to strip the extension from a filename variable (i.e. retrieve the basename).
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.curlybrace.com/words/2010/02/05/converting-mp3-to-aac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Tunneling Windows RDC</title>
		<link>http://www.curlybrace.com/words/2009/07/05/ssh-port-forwarding-windows-rdc/</link>
		<comments>http://www.curlybrace.com/words/2009/07/05/ssh-port-forwarding-windows-rdc/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 22:26:17 +0000</pubDate>
		<dc:creator>Jeff Fitzsimons</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.curlybrace.com/words/?p=740</guid>
		<description><![CDATA[This article explains how to securely port-forward Windows Remote Desktop (Terminal Services) over SSH, using standard SSH command line syntax. If you prefer to use GUI SSH tools, such as PuTTY, there are other guides for that. Terminology Notes My &#8230; <a href="http://www.curlybrace.com/words/2009/07/05/ssh-port-forwarding-windows-rdc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This article explains how to securely port-forward Windows Remote Desktop (Terminal Services) over SSH, using standard SSH command line syntax.  If you prefer to use GUI SSH tools, such as PuTTY, <a href="http://theillustratednetwork.mvps.org/Ssh/RemoteDesktopSSH.html">there are other guides for that</a>.</p>
<h4>Terminology Notes</h4>
<p>My terminology assumes that you are connecting to a machine on your home network, which is protected by a firewall.  However, the diagrams and commands are valid regardless of whether the remote network is at home or not.</p>
<p>Additionally, I use <tt><i>RDCHOST</i></tt> to represent the local name or IP of your RDC server <b>within the home network</b>, and <tt><i>my_home_ip</i></tt> to represent your home IP address as visible from the Internet.</p>
<h3>Prerequisites</h3>
<ul>
<li />Depending on network configuration, port-forwarding may have to be configured on the firewall.
<li />An SSH client (e.g. <a href="http://www.cygwin.com/">Cygwin&#8217;s OpenSSH</a> for Windows) must be installed on the local machine.
<li />An SSH server (e.g. <a href="http://www.cygwin.com/">Cygwin&#8217;s OpenSSHD</a> for Windows) must be present on some machine within the home network.
<li />SSH keys must be generated and deployed appropriately.
</ul>
<h3>SSH Command Syntax</h3>
<blockquote><p><tt>ssh -C -N -L <i>localPort</i>:<i>destinationHost</i>:3389 <i>proxyHost</i></tt></p>
<p />
<ul>
<li /><i>localPort</i> is the port on localhost through which you wish to connect.
<li /><i>destinationHost</i> is the Remote Desktop host, <b>as it appears on the home network</b>.
<li /><i>proxyHost</i> is the host running SSHD, through which you will tunnel.
</ul>
</blockquote>
<h3>Configuration 1:  Discrete Servers</h3>
<p>This configuration has the firewall port-forward SSH to a server on the home network, which proxies the connection to the RDC server:</p>
<blockquote><pre>                       +-----------[ Home Network ]---------------+
                       |                                          |
localhost <----> Home Firewall <---> SSH Server <---> RDC Server  |
                       |                                          |
                       +------------------------------------------+</pre>
</blockquote>
<p>Command line:</p>
<blockquote><p><tt>ssh -C -N -L 6009:<i>RDCHOST</i>:3389 <i>my_home_ip</i></tt></p></blockquote>
<h3>Configuration 2:  Combined RDC &#038; SSH Servers</h3>
<p>In this configuration, the RDC server also has an SSH server, and the firewall port-forwards directly to it:</p>
<blockquote><pre>                       +------[ Home Network ]-----+
                       |                           |
localhost <----> Home Firewall <-----> RDC &#038; SSH   |
                       |                Server     |
                       +---------------------------+</pre>
</blockquote>
<p>Command line:</p>
<blockquote><p><tt>ssh -C -N -L 6009:localhost:3389 <i>my_home_ip</i></tt></p></blockquote>
<h3>Configuration 3:  Firewall as SSH Server</h3>
<p>In this configuration, the firewall acts as the SSH server, proxying the connection directly to the RDC server on the home network:</p>
<blockquote><pre>                       +----[ Home Network ]----+
                       |                        |
localhost <----> Home Firewall <---> RDC Server |
                  &#038; SSH Server                  |
                       |                        |
                       +------------------------+
</pre>
</blockquote>
<p>Command line:</p>
<blockquote><p><tt>ssh -C -N -L 6009:<i>RDCHOST</i>:3389 <i>my_home_ip</i></tt></p></blockquote>
<h3>Additional Suggestions</h3>
<p>Rather than specifying the IP address of your home firewall, I suggest using <a href="http://www.dyndns.com/">DynDNS</a> to get a dynamic DNS entry.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.curlybrace.com/words/2009/07/05/ssh-port-forwarding-windows-rdc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Organizing Files by Date Using Find</title>
		<link>http://www.curlybrace.com/words/2008/07/13/organizing-files-by-date-using-find/</link>
		<comments>http://www.curlybrace.com/words/2008/07/13/organizing-files-by-date-using-find/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 19:10:42 +0000</pubDate>
		<dc:creator>Jeff Fitzsimons</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.curlybrace.com/words/?p=147</guid>
		<description><![CDATA[I had taken pictures using a friend&#8217;s SD card. He copied all the files to my flash drive, but this left me without a nice, tidy directory structure. Normally, I organize my photos like: 2008 2008_06_27 2008_06_28 2008_06_29 First off, &#8230; <a href="http://www.curlybrace.com/words/2008/07/13/organizing-files-by-date-using-find/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had taken pictures using a friend&#8217;s SD card.  He copied all the files to my flash drive, but this left me without a nice, tidy directory structure.  Normally, I organize my photos like:</p>
<blockquote><pre>2008
   2008_06_27
   2008_06_28
   2008_06_29</pre>
</blockquote>
<p>First off, I needed to list the files by date:</p>
<blockquote><pre>ls -lt</pre>
</blockquote>
<p>This showed me that I had files from the 27th, 28th, and 29th in a single directory.  So I created a directory for each date.</p>
<p>Next, I used <tt>find</tt> with the <tt>-newer</tt> and <tt>-exec</tt> switches to execute a move command on each file newer than a particular file.</p>
<p>By looking at the <tt>ls -lt</tt> output, I found the last photo taken on each day.  IMG_6369.JPG was the last taken on the 28th, and IMG_6284.JPG was the last taken on the 27th.</p>
<p>To move all of the files taken on the 28th and 29th, I used this command:</p>
<blockquote><pre>find . -type f -newer IMG_6284.JPG -exec mv {} 2008_06_28 \;</pre>
</blockquote>
<p>Now, all files taken after the 27th are located in the 2008_06_28 directory.  Now, I change into that directory, and execute:</p>
<blockquote><pre>find . -type f -newer IMG_6369.JPG -exec mv {} ../2008_06_29 \;</pre>
</blockquote>
<p>Now I&#8217;m left with all the photos from the 27th in the main directory.  Those could easily be moved with:</p>
<blockquote><pre>find . -maxdepth 1 -type f -exec mv {} ../2008_06_27 \;</pre>
</blockquote>
<p>I&#8217;m sure there is a quicker, cleaner way to do this, but for the limited number of subdirectories I had to filter into, this was reasonably efficient.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.curlybrace.com/words/2008/07/13/organizing-files-by-date-using-find/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extracting a Version Number From a Text File Using Batch Files and Cygwin</title>
		<link>http://www.curlybrace.com/words/2008/07/11/extracting-a-version-number/</link>
		<comments>http://www.curlybrace.com/words/2008/07/11/extracting-a-version-number/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 01:50:47 +0000</pubDate>
		<dc:creator>Jeff Fitzsimons</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.curlybrace.com/words/?p=146</guid>
		<description><![CDATA[We have a version.h file. It contains lines such as: #define VERSION_MAJOR 3 #define VERSION_MINOR 1 By piping this through grep, I can get the line I&#8217;m looking for: c:\>grep "VERSION_MAJOR" version.h #define VERSION_MAJOR 3 But what I really want &#8230; <a href="http://www.curlybrace.com/words/2008/07/11/extracting-a-version-number/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We have a version.h file.  It contains lines such as:</p>
<blockquote><pre>#define VERSION_MAJOR     3
#define VERSION_MINOR     1</pre>
</blockquote>
<p>By piping this through <tt>grep</tt>, I can get the line I&#8217;m looking for:</p>
<blockquote><pre>c:\>grep "VERSION_MAJOR" version.h
#define VERSION_MAJOR     3</pre>
</blockquote>
<p>But what I really want is the version number within the line, so I pipe this through <tt>sed</tt>:</p>
<blockquote><pre>c:\>grep "VERSION_MAJOR" version.h | sed -e "s/^.* VERSION_MAJOR\s*\([0-9]\+\)/\1/g"
3</pre>
</blockquote>
<p>So now we have extracted the version number corresponding to &#8220;VERSION_MAJOR&#8221;.  However, in order to conditionally branch in our batch script, we need to get this value into an environmental variable.  In bash, this would be accomplished with backticks.  As it turns out, Windows batch files <b>do</b> provide similar functionality, but through a much clumsier means:</p>
<blockquote><pre>c:\>for /f "tokens=3" %i in ('grep " VERSION_MAJOR" version.h') do set MAJORVERSION=%i
c:\>echo %MAJORVERSION%
3</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.curlybrace.com/words/2008/07/11/extracting-a-version-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stripping Vertical Whitespace Using tr</title>
		<link>http://www.curlybrace.com/words/2008/06/16/stripping-vertical-whitespace-tr/</link>
		<comments>http://www.curlybrace.com/words/2008/06/16/stripping-vertical-whitespace-tr/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 18:05:37 +0000</pubDate>
		<dc:creator>Jeff Fitzsimons</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.curlybrace.com/words/?p=130</guid>
		<description><![CDATA[The Translate command, tr, is available on all Unix-y systems, including Cygwin. tr -d will delete the specified characters from a stream. Several handy escape sequences are provided for stripping newlines, carriage returns, and form-feeds: \f &#8211; form feed \n &#8230; <a href="http://www.curlybrace.com/words/2008/06/16/stripping-vertical-whitespace-tr/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Translate command, <tt>tr</tt>, is available on all Unix-y systems, including <a href="http://www.cygwin.com">Cygwin</a>.  <tt>tr -d</tt> will delete the specified characters from a stream.   Several handy escape sequences are provided for stripping newlines, carriage returns, and form-feeds:</p>
<ul>
<li /><tt>\f</tt> &#8211; form feed
<li /><tt>\n</tt> &#8211; new line
<li /><tt>\r</tt> &#8211; return
</ul>
<p>Since <tt>tr</tt> is deleting <i>characters</i>, not strings, we can simply specify all of these in a single command:</p>
<blockquote><p><tt>cat input.txt | tr -d \r\n\f > output.txt</tt></p></blockquote>
<p>Another way to assemble this command:</p>
<blockquote><p><tt>tr -d \r\n\f < input.txt > output.txt</tt></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.curlybrace.com/words/2008/06/16/stripping-vertical-whitespace-tr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

