<?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>John&#039;s Blog &#187; bash</title>
	<atom:link href="http://john.nachtimwald.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://john.nachtimwald.com</link>
	<description>My little blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 21:11:32 +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>Duplicity Backup Script</title>
		<link>http://john.nachtimwald.com/2010/08/07/duplicity-backup-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=duplicity-backup-script</link>
		<comments>http://john.nachtimwald.com/2010/08/07/duplicity-backup-script/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 20:59:16 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[duplicity]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://john.nachtimwald.com/?p=464</guid>
		<description><![CDATA[I&#8217;ve started using duplicity combined with Amazon&#8217;s S3 to backup this server. Duplicity is an amazing application that makes backups simple. Some of the features I like best about duplicity are: it encrypts the data, compresses it, splits it into manageable chunks, does incremental backups, and can backup to a variety of destinations. When you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started using <a href="http://duplicity.nongnu.org/">duplicity</a> combined with Amazon&#8217;s <a href="https://s3.amazonaws.com/">S3</a> to backup this server. Duplicity is an amazing application that makes backups simple.</p>
<p>Some of the features I like best about duplicity are: it encrypts the data, compresses it, splits it into manageable chunks, does incremental backups, and can backup to a variety of destinations. When you restore your data it takes care of applying the incremental backups to produce the final files. Also, duplicity can be used to restore previous versions of stored files.</p>
<p>Overall I&#8217;m very happy with using duplicity for pushing automatic backups to my S3 account. To make it easier to use and so that I can run it from a cron job I&#8217;ve written a simple bash script to handle calling duplicity with the correct options. The script also dumps my MySQL databases and pushes them separately to a different S3 bucket.</p>
<p>Following is a variant of the script I&#8217;m using on my server. This one is a bit more generic and allows for MySQL backups to be turned off as well as some basic dependency checking. It also allows for some simple option tuning. The version I use has most of the options hard coded in the appropriate place instead of putting them into variables. This script is mostly tested.</p>
<p>***Edit: minor changes to the script. It should have only been checking for MySQL commands when MySQL backup is enabled.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Duplicity Setup ###</span>
<span style="color: #007800;">PASSPHRASE</span>=<span style="color: #ff0000;">&quot;&lt;your passphrase&gt;&quot;</span>
<span style="color: #007800;">AWS_ACCESS_KEY_ID</span>=<span style="color: #ff0000;">&quot;&lt;your key id&gt;&quot;</span>
<span style="color: #007800;">AWS_SECRET_ACCESS_KEY</span>=<span style="color: #ff0000;">&quot;&lt;your secret key&gt;&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This needs to be a newline separated list of files and directories to backup</span>
<span style="color: #007800;">INCLUDEFILES</span>=<span style="color: #ff0000;">&quot;/etc/duplicity/server-filelist.txt&quot;</span>
&nbsp;
<span style="color: #007800;">S3FILESYSLOCATION</span>=<span style="color: #ff0000;">&quot;s3+http://&lt;your file bucket&gt;&quot;</span>
<span style="color: #007800;">S3MYSQLLOCATION</span>=<span style="color: #ff0000;">&quot;s3+http://&lt;your mysql bucket&gt;&quot;</span>
<span style="color: #007800;">S3OPTIONS</span>=<span style="color: #ff0000;">&quot;--s3-use-new-style --s3-use-rrs&quot;</span>
&nbsp;
<span style="color: #007800;">EXTRADUPLICITYOPTIONS</span>=
&nbsp;
<span style="color: #007800;">FULLDAYS</span>=<span style="color: #ff0000;">&quot;30D&quot;</span>
<span style="color: #007800;">MAXFULL</span>=<span style="color: #000000;">3</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### MySQL Setup ###</span>
<span style="color: #007800;">MUSER</span>=<span style="color: #ff0000;">&quot;&lt;your mysql user&gt;&quot;</span>
<span style="color: #007800;">MPASS</span>=<span style="color: #ff0000;">&quot;&lt;mysql user's password&gt;&quot;</span>
<span style="color: #007800;">MHOST</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Disable MySQL ###</span>
<span style="color: #666666; font-style: italic;"># Change to 0 to disable</span>
<span style="color: #007800;">BACKUPMYSQL</span>=<span style="color: #000000;">1</span>
&nbsp;
<span style="color: #666666; font-style: italic;">###### End Of Editable Parts ######</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Env Vars ###</span>
<span style="color: #007800;">PASSPHRASE_OLD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(echo $PASSPHRASE)</span>&quot;</span>
<span style="color: #007800;">AWS_ACCESS_KEY_ID_OLD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(echo $AWS_ACCESS_KEY_ID)</span>&quot;</span>
<span style="color: #007800;">AWS_SECRET_ACCESS_KEY_OLD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(echo $AWS_SECRET_ACCESS_KEY)</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PASSPHRASE</span>=<span style="color: #007800;">$PASSPHRASE</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">AWS_ACCESS_KEY_ID</span>=<span style="color: #007800;">$AWS_ACCESS_KEY_ID</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">AWS_SECRET_ACCESS_KEY</span>=<span style="color: #007800;">$AWS_SECRET_ACCESS_KEY</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Commands ###</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #007800;">MYSQLTMPDIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(mktemp -d)</span>&quot;</span>
 <span style="color: #007800;">MYSQL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which mysql)</span>&quot;</span>
 <span style="color: #007800;">MYSQLDUMP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which mysqldump)</span>&quot;</span>
 <span style="color: #007800;">GZIP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which gzip)</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #007800;">DUPLICITY</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which duplicity)</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MYSQLDUMP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$GZIP</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Not all MySQL commands found.&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
 <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUPLICITY</span>&quot;</span>  <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Duplicity not found.&quot;</span>
 <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Dump MySQL Databases ###</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #666666; font-style: italic;"># Get all databases name</span>
 <span style="color: #007800;">DBS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')</span>&quot;</span>
 <span style="color: #000000; font-weight: bold;">for</span> db <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$DBS</span>
 <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$db</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;information_schema&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #007800;">$MYSQLDUMP</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$MUSER</span> <span style="color: #660033;">-h</span> <span style="color: #007800;">$MHOST</span> -p<span style="color: #007800;">$MPASS</span> <span style="color: #007800;">$db</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$GZIP</span> <span style="color: #660033;">-9</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$MYSQLTMPDIR</span><span style="color: #000000; font-weight: bold;">/</span>mysql-<span style="color: #007800;">$db</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
 <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Backup files ###</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$S3FILESYSLOCATION</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #007800;">$DUPLICITY</span> <span style="color: #660033;">--full-if-older-than</span> <span style="color: #007800;">$FULLDAYS</span> <span style="color: #007800;">$S3OPTIONS</span> <span style="color: #007800;">$EXTRADUPLICITYOPTIONS</span> <span style="color: #660033;">--include-globbing-filelist</span> <span style="color: #007800;">$INCLUDEFILES</span> <span style="color: #660033;">--exclude</span> <span style="color: #ff0000;">'**'</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #007800;">$S3FILESYSLOCATION</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$S3MYSQLLOCATION</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">$DUPLICITY</span> <span style="color: #660033;">--full-if-older-than</span> <span style="color: #007800;">$FULLDAYS</span> <span style="color: #007800;">$S3OPTIONS</span> <span style="color: #007800;">$EXTRADUPLICITYOPTIONS</span> <span style="color: #660033;">--allow-source-mismatch</span> <span style="color: #007800;">$MYSQLTMPDIR</span> <span style="color: #007800;">$S3MYSQLLOCATION</span>
 <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Cleanup ###</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MAXFULL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MAXFULL</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$S3FILESYSLOCATION</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">$DUPLICITY</span> remove-all-but-n-full <span style="color: #007800;">$MAXFULL</span> <span style="color: #007800;">$S3FILESYSLOCATION</span>
 <span style="color: #000000; font-weight: bold;">fi</span>
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$S3MYSQLLOCATION</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #007800;">$DUPLICITY</span> remove-all-but-n-full <span style="color: #007800;">$MAXFULL</span> <span style="color: #007800;">$S3MYSQLLOCATION</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
 <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPMYSQL</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$MYSQLTMPDIR</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PASSPHRASE</span>=<span style="color: #007800;">$PASSPHRASE_OLD</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">AWS_ACCESS_KEY_ID</span>=<span style="color: #007800;">$AWS_ACCESS_KEY_ID_OLD</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">AWS_SECRET_ACCESS_KEY</span>=<span style="color: #007800;">$AWS_SECRET_ACCESS_KEY_OLD</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://john.nachtimwald.com/2010/08/07/duplicity-backup-script/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Multiple Input with Single Input Apps</title>
		<link>http://john.nachtimwald.com/2008/12/24/multiple-input-with-single-input-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=multiple-input-with-single-input-apps</link>
		<comments>http://john.nachtimwald.com/2008/12/24/multiple-input-with-single-input-apps/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 23:36:42 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ebook]]></category>

		<guid isPermaLink="false">http://john.nachtimwald.com/?p=61</guid>
		<description><![CDATA[The few eBook formating tools I&#8217;ve posted all share one major flaw. They can only handle a single file as input. This is a problem when you want to run it on all or a number of different eBooks. If you are able to use Bash there is a simple way to run any single [...]]]></description>
			<content:encoded><![CDATA[<p>The few eBook formating tools I&#8217;ve posted all share one major flaw. They can only handle a single file as input. This is a problem when you want to run it on all or a number of different eBooks. If you are able to use Bash there is a simple way to run any single input command with multiple items.</p>
<p>This first method gets input from a single directory. This method will not go into subdirectories for input.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Books<span style="color: #000000; font-weight: bold;">/</span>author
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">*</span>.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #c20cb9; font-weight: bold;">file</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$file</span>; .<span style="color: #000000; font-weight: bold;">/</span>fix_paragraphs_ebook_txt <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>; .<span style="color: #000000; font-weight: bold;">/</span>remove_extra_whitespace_ebook_txt <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>This second method gets all files matching the given pattern and will handle subdirectories.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> ~<span style="color: #000000; font-weight: bold;">/</span>books<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*.txt&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #c20cb9; font-weight: bold;">file</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>; dos2unix <span style="color: #660033;">-ad</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>; .<span style="color: #000000; font-weight: bold;">/</span>fix_end_ebook_txt <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://john.nachtimwald.com/2008/12/24/multiple-input-with-single-input-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

