<?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>GNU/Linux on BoochTek, LLC</title><link>https://blog.boochtek.com/categories/gnu/linux/</link><description>Recent content in GNU/Linux on BoochTek, LLC</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 11 Mar 2014 23:28:22 +0000</lastBuildDate><atom:link href="https://blog.boochtek.com/categories/gnu/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>Burying the Lede</title><link>https://blog.boochtek.com/posts/readable-shell-scripts/</link><pubDate>Tue, 11 Mar 2014 23:28:22 +0000</pubDate><guid>https://blog.boochtek.com/posts/readable-shell-scripts/</guid><description>&lt;p&gt;Most of us don&amp;rsquo;t write very readable shell scripts. There are plenty of things we could do better, but today I want to talk about one in particular &amp;mdash; burying the lede.&lt;/p&gt;
&lt;p&gt;The term &amp;ldquo;burying the lede&amp;rdquo; comes from the field of journalism. Here&amp;rsquo;s the &lt;a href="http://en.wiktionary.org/wiki/bury_the_lede"&gt;Wiktionary definition&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;To begin a story with details of secondary importance to the reader while postponing more essential points or facts.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Like a good news article, code should tell a story. And the story should start with what&amp;rsquo;s most important. In the case of code, the most important information is the high-level functionality &amp;mdash; a succinct summary of what the program does. In other words, write (and organize) the code top-down, as opposed to bottom-up.&lt;/p&gt;</description></item><item><title>Bulk Rename in Bash</title><link>https://blog.boochtek.com/posts/bulk-rename-in-bash/</link><pubDate>Fri, 26 Aug 2011 22:53:58 +0000</pubDate><guid>https://blog.boochtek.com/posts/bulk-rename-in-bash/</guid><description>&lt;p&gt;Here&amp;rsquo;s a relatively simple way to rename a bunch of files from the command line. It uses &lt;code&gt;sed&lt;/code&gt; within a command substitution to compute the new names from the old names.&lt;/p&gt;
&lt;p&gt;In this example, we&amp;rsquo;re renaming files that start with &amp;ldquo;ABC&amp;rdquo; to start with &amp;ldquo;XYZ&amp;rdquo; instead:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i in ABC*; &lt;span style="color:#66d9ef"&gt;do&lt;/span&gt; mv $i &lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;echo $i | sed -e s/^ABC/XYZ/&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;; &lt;span style="color:#66d9ef"&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ll have to use shell globbing (wildcards) in the first part, to determine which files will be the source of the renaming, and regular expressions in the second part to translate the old names into the new names.&lt;/p&gt;</description></item></channel></rss>