<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Bash on Red Leopard</title>
    <link>https://www.redleopard.com/tags/bash/</link>
    <description>Recent content in Bash on Red Leopard</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 15 Oct 2010 08:48:22 +0000</lastBuildDate>
    <atom:link href="https://www.redleopard.com/tags/bash/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>filenames with spaces</title>
      <link>https://www.redleopard.com/2010/10/filenames-with-spaces/</link>
      <pubDate>Fri, 15 Oct 2010 08:48:22 +0000</pubDate>
      <guid>https://www.redleopard.com/2010/10/filenames-with-spaces/</guid>
      <description>&lt;p&gt;I downloaded &lt;a href=&#34;http://unity3d.com&#34;&gt;Unity&lt;/a&gt; last week. My first bit of installation geekery was to push the documentation to marmaduke, my CentOS server. I drop the documentation directory into a virtual host and let apache serve the index (since I solved my &lt;a href=&#34;http://www.redleopard.com/2009/12/apache-directory-indexing/&#34;&gt;Apache Directory Indexing&lt;/a&gt; problem a bit back.)&lt;/p&gt;
&lt;p&gt;However, I found that the pages had missing images. Looking at the HTML source, I found that some of the image URLs used ‘images’ (lower case i) while others used ‘Images’ (upper case I). To make matters worse, CSS and javascript files were also stored in the images directory.&lt;/p&gt;</description>
    </item>
    <item>
      <title>bash uuid generator</title>
      <link>https://www.redleopard.com/2010/03/bash-uuid-generator/</link>
      <pubDate>Thu, 25 Mar 2010 04:20:50 +0000</pubDate>
      <guid>https://www.redleopard.com/2010/03/bash-uuid-generator/</guid>
      <description>&lt;p&gt;Onliner bash scripts are handy but bash and common utilities don’t always work the same on the two systems I most use: Centos vs. OS X.&lt;/p&gt;
&lt;div class=&#34;terminal&#34;&gt;
  &lt;pre&gt;
centos $ &lt;span style=&#34;color: green;&#34;&gt;cat /etc/redhat-release &lt;/span&gt;
CentOS release 5.4 (Final)
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&#34;terminal&#34;&gt;
  &lt;pre&gt;
osx $ &lt;span style=&#34;color: green;&#34;&gt;sw_vers | head -n2&lt;/span&gt;
ProductName:	Mac OS X
ProductVersion:	10.6.2
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;For example, I recently wrote a simple script to generate a set of &lt;a href=&#34;http://en.wikipedia.org/wiki/Uuid&#34;&gt;UUID&lt;/a&gt; using the &lt;code&gt;uuidgen&lt;/code&gt; utility. OS X and Centos versions of &lt;code&gt;uuidgen&lt;/code&gt; take very different parameters.&lt;/p&gt;</description>
    </item>
    <item>
      <title>bash date tricks</title>
      <link>https://www.redleopard.com/2009/08/bash-date-tricks/</link>
      <pubDate>Sun, 16 Aug 2009 21:14:39 +0000</pubDate>
      <guid>https://www.redleopard.com/2009/08/bash-date-tricks/</guid>
      <description>&lt;p&gt;A quick usage note regarding the date util under bash. I sometimes want to convert between a &lt;a href=&#34;http://en.wikipedia.org/wiki/Unix_timestamp&#34;&gt;unix timestamp&lt;/a&gt; and a formatted date string. I do it infrequently enough that I forget the syntax. This article is me writing down my notes.&lt;/p&gt;
&lt;p&gt;In the following example, I want to get timestamps and date strings for both today and yesterday. Why yesterday’s date? Because I want to get yesterday’s data from google analytics’ data API. I’ve see numerous examples getting day, month and year then subtracting one from the day and propagating the underflow through the month and year. Blech! If I have today’s timestamp, I simply subtract a days worth of seconds from today and violà, yesterday!&lt;/p&gt;</description>
    </item>
    <item>
      <title>use curl for api documentation</title>
      <link>https://www.redleopard.com/2009/04/use-curl-for-api-documentation/</link>
      <pubDate>Thu, 02 Apr 2009 18:08:03 +0000</pubDate>
      <guid>https://www.redleopard.com/2009/04/use-curl-for-api-documentation/</guid>
      <description>&lt;p&gt;I’ve been working quite a bit with the &lt;a href=&#34;http://cwiki.apache.org/S2PLUGINS/rest-plugin.html&#34;&gt;rest plugin&lt;/a&gt; for &lt;a href=&#34;http://struts.apache.org/&#34;&gt;Struts2&lt;/a&gt;. The really nice thing about this plugin is the way it cleans up Struts URLs. Makes them more rails-like. I chuckled when &lt;a href=&#34;http://depressedprogrammer.wordpress.com/2007/04/04/struts-2-and-zero-configuration-for-actions-and-results/&#34;&gt;depressed programmer&lt;/a&gt; suggested that struts2 is “WebWork on drugs.” I hate struts2. I really do.&lt;/p&gt;
&lt;p&gt;Anyway, I have stripped down an AccountController to show just the POST service. In reality, the create() method is wired to a middle tier service that authenticates username, password pairs then updates session attributes with member id and other bits of persistent session data I need.&lt;/p&gt;</description>
    </item>
    <item>
      <title>bash progress monitor</title>
      <link>https://www.redleopard.com/2009/01/bash-progress-monitor/</link>
      <pubDate>Sat, 10 Jan 2009 05:55:28 +0000</pubDate>
      <guid>https://www.redleopard.com/2009/01/bash-progress-monitor/</guid>
      <description>&lt;p&gt;I have a remote machine that is used to store and process XML files. Recently, I had need to duplicate a directory of XML files (e.g., cp -r a b). It’s not really germane to the subject here, but this particular server has a whack configuration and I gotta rant before I continue.&lt;/p&gt;
&lt;p&gt;The office server (&lt;a href=&#34;http://en.wikipedia.org/wiki/Scrappy-Doo&#34;&gt;scrappy&lt;/a&gt;) has pretty good specs.&lt;/p&gt;
&lt;div class=&#34;terminal&#34;&gt;
  &lt;pre&gt;
[scrappy ~]$ cat /proc/meminfo
&lt;p&gt;MemTotal:      3980800 kB&lt;/p&gt;
&lt;p&gt;[scrappy ~]$ cat /proc/cpuinfo&lt;/p&gt;</description>
    </item>
    <item>
      <title>grep and UTF-8</title>
      <link>https://www.redleopard.com/2008/12/grep-and-utf-8/</link>
      <pubDate>Wed, 24 Dec 2008 01:44:24 +0000</pubDate>
      <guid>https://www.redleopard.com/2008/12/grep-and-utf-8/</guid>
      <description>&lt;p&gt;I needed to look up the various strings Apple uses to name the iTunes Library. First I tried to get name from the iTunes resource bundle&lt;/p&gt;
&lt;div class=&#34;terminal&#34;&gt;
  &lt;pre&gt;
echo &#34;this won&#39;t work...&#34;
echo &#34;so don&#39;t even try it&#34;
&lt;p&gt;cd /Applications/iTunes.app/Contents/Resources/English.lproj
cat Localizable.strings | grep &amp;lsquo;PrimaryPlaylistName&amp;rsquo;
&lt;/pre&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;But I quickly learned that grep doesn’t work on the strings file. Why? Because &lt;a href=&#34;http://developer.apple.com/DOCUMENTATION/MacOSX/Conceptual/BPInternational/Articles/StringsFiles.html#//apple_ref/doc/uid/20000005-SW15&#34;&gt;Apple string files&lt;/a&gt; are not UTF-8. They are UTF-16. Usually. But in this case they are. I wanted to iterate over the set of resource strings and extract just the string I wanted.&lt;/p&gt;</description>
    </item>
    <item>
      <title>centos l10n problem</title>
      <link>https://www.redleopard.com/2008/12/centos-l10n-problem/</link>
      <pubDate>Thu, 18 Dec 2008 02:46:03 +0000</pubDate>
      <guid>https://www.redleopard.com/2008/12/centos-l10n-problem/</guid>
      <description>&lt;p&gt;Just about the time I believe the UTF-8 beast is in the cage, it escapes and runs amok.&lt;/p&gt;
&lt;p&gt;This AM, I started to deploy an update to the webapp on &lt;a href=&#34;http://aws.amazon.com/ec2/&#34;&gt;EC2&lt;/a&gt;. Seems that some of the static strings in the app contained UTF-8 encoded non-ascii characters. The java compiler barfed. “The heck?”, I thought. I just compiled the app on my MacBook. I checked the usual suspects (tomcat’s server.xml, JAVA_OPTS) but everything looked fine. However, when I looked at the code, it was indeed mangled.&lt;/p&gt;</description>
    </item>
    <item>
      <title>bash array crawler</title>
      <link>https://www.redleopard.com/2008/12/bash-array-crawler/</link>
      <pubDate>Thu, 18 Dec 2008 02:18:06 +0000</pubDate>
      <guid>https://www.redleopard.com/2008/12/bash-array-crawler/</guid>
      <description>&lt;p&gt;I wanted to complement my &lt;a href=&#34;http://www.redleopard.com/2008/12/bash-directory-crawler/&#34;&gt;bash directory crawler&lt;/a&gt; post with a bash array crawler example.&lt;/p&gt;
&lt;p&gt;Sometimes, it’s easier to jack a list of identifying tokens into an array and process them rather than to build an end-to-end script with database access. For this contrived example, I grab a list of &lt;a href=&#34;http://www.famkruithof.net/uuid/uuidgen&#34;&gt;UUID&lt;/a&gt; from MySQL with a simple SQL statement.&lt;/p&gt;
&lt;div class=&#34;terminal&#34;&gt;
  &lt;pre&gt;
mysql&gt; SELECT id, uuid FROM icons;
+-----+--------------------------------------+
| id  | uuid                                 |
+-----+--------------------------------------+
|   1 | fe0b16ed-3369-4dda-8e60-faffb966375d |
|   3 | 82bfcbc2-84a2-4ca7-914b-13172b94feb6 |
|   6 | ab5e7265-3698-4205-b081-e6aec528fee2 |
|  11 | 4b6ca26b-c6ed-494f-aeb4-9bf369e2d465 |
|  19 | e7cc807b-7f15-46fa-b1c5-85d1f1050155 |
+-----+--------------------------------------+
5 rows in set (0.00 sec)
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Next, jack the tokens into an array and simply crawl over the tokens.&lt;/p&gt;</description>
    </item>
    <item>
      <title>EC2 and S3 Success Story</title>
      <link>https://www.redleopard.com/2008/12/ec2-and-s3-success-story/</link>
      <pubDate>Thu, 11 Dec 2008 02:09:36 +0000</pubDate>
      <guid>https://www.redleopard.com/2008/12/ec2-and-s3-success-story/</guid>
      <description>&lt;p&gt;I’ve been building systems lately on Amazon’s &lt;a href=&#34;http://aws.amazon.com/ec2/&#34;&gt;Elastic Compute Cloud&lt;/a&gt; (EC2). At first, I was only interested in Amazon’s &lt;a href=&#34;http://aws.amazon.com/s3/&#34;&gt;Simple Storage Solution&lt;/a&gt; (S3) after seeing the SmugMug &lt;a href=&#34;http://www.slideshare.net/techdude/scalability-set-amazons-servers-on-fire-not-yours/&#34;&gt;slide show&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I hadn’t really considered using EC2 since we had more servers in colocation than I really needed. But I had a file storage problem. When you have a thousand files, you stick them in a directory. When you have a million files, you cannot simply stick them in a single directory. You distribute them across multiple directories. What a PITA.&lt;/p&gt;</description>
    </item>
    <item>
      <title>bash directory crawler</title>
      <link>https://www.redleopard.com/2008/12/bash-directory-crawler/</link>
      <pubDate>Thu, 04 Dec 2008 19:44:21 +0000</pubDate>
      <guid>https://www.redleopard.com/2008/12/bash-directory-crawler/</guid>
      <description>&lt;p&gt;Currently, popular filesystems (ext3, hfs+) have a practical limit on the number of files and directories you can store in a single directory. Certainly, most of the unix command line tools will not work once you exceed some magic threshold. In my experience, 10,000 files and or directories is the practical limit.&lt;/p&gt;
&lt;p&gt;So what do you do when you have 1,000,000 XML files to process? I had this very problem recently. Fortunately, the problem was simplified as each file belong to one of 27,000 categories.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Fuser Detects FTP Completion</title>
      <link>https://www.redleopard.com/2008/11/fuser-detects-ftp-completion/</link>
      <pubDate>Tue, 25 Nov 2008 19:28:57 +0000</pubDate>
      <guid>https://www.redleopard.com/2008/11/fuser-detects-ftp-completion/</guid>
      <description>&lt;p&gt;At work, we have legacy systems with problems which no one had taken the time to fix. One such legacy problem involved an FTP server. Client applications would FTP files up to the server for processing. That part worked fine. What didn’t work was knowing when the FTP was complete so we could start processing the data.&lt;/p&gt;
&lt;p&gt;Recently, I decided to fix this problem.&lt;/p&gt;
&lt;p&gt;Many people have written on the subject. One of the approaches advised, “watching the file and when the file size stops changing, you can use it.” I didn’t like that one. For &lt;em&gt;so&lt;/em&gt; many reasons. &lt;a href=&#34;http://www.usenet-forums.com/linux-general/83329-how-detect-locked-files.html&#34;&gt;Another&lt;/a&gt; recommended using &lt;code&gt;lsof&lt;/code&gt;. Hummmmmmm. I didn’t get a warm fuzzy feeling with that one either.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
