<?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>Olle Jonsson&#039;s blog &#187; unix</title>
	<atom:link href="http://ollehost.dk/blog/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://ollehost.dk/blog</link>
	<description></description>
	<lastBuildDate>Tue, 22 May 2012 20:28:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using find</title>
		<link>http://ollehost.dk/blog/2010/08/30/880/</link>
		<comments>http://ollehost.dk/blog/2010/08/30/880/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 09:05:41 +0000</pubDate>
		<dc:creator>olleolleolle</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://ollehost.dk/blog/?p=880</guid>
		<description><![CDATA[When not using ack, my favorite search tool, you can still exclude SVN folders. Here is an example of me looking for a file: $ find . -not \( -name .svn -prune \) -name 'EosController*' ./web/models/controllers/EosController.php ./web/models/controllers/EosControllerTest.php This mode of &#8230; <a href="http://ollehost.dk/blog/2010/08/30/880/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When not using <a href="http://betterthangrep.com/">ack</a>, my favorite search tool, you can still exclude SVN folders. Here is an example of me looking for a file:</p>
<p><code>$ find . -not \( -name .svn -prune \) -name 'EosController*'<br />
    ./web/models/controllers/EosController.php<br />
    ./web/models/controllers/EosControllerTest.php<br />
</code></p>
<p>This mode of expression might be better for your scripting needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://ollehost.dk/blog/2010/08/30/880/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>unix search-and-replace: rpl (and sed)</title>
		<link>http://ollehost.dk/blog/2007/05/07/unix-search-and-replace-rpl/</link>
		<comments>http://ollehost.dk/blog/2007/05/07/unix-search-and-replace-rpl/#comments</comments>
		<pubDate>Mon, 07 May 2007 15:43:25 +0000</pubDate>
		<dc:creator>olleolleolle</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[textprocessing]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://ollehost.dk/blog/?p=344</guid>
		<description><![CDATA[Evan showed the world his &#8220;weak Ruby script&#8221; to find-and-replace in multiple files, and was pointed to the amazing rpl utility. Let&#8217;s see what the port maintainer has written about the rpl tool. $ port info rpl rpl 1.4.0, textproc/rpl &#8230; <a href="http://ollehost.dk/blog/2007/05/07/unix-search-and-replace-rpl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Evan showed the world his &#8220;<a href="http://blog.evanweaver.com/articles/2007/04/04/dumb-multi-file-find-and-replace">weak Ruby script</a>&#8221; to find-and-replace in multiple files, and was pointed to the amazing <code>rpl</code> utility. </p>
<p>Let&#8217;s see what the port maintainer has written about the rpl tool.</p>
<pre><code>
$ port info rpl
rpl 1.4.0, textproc/rpl (Variants: universal)

http://www.laffeycomputer.com/rpl.html

rpl is a Unix text replacement utility. It will replace strings with new
strings in multiple text files. It can scan directories recursively and
replace strings in all files found. The search can be limited to files with
certain filename suffixes (e.g. '.html', '.c', etc.).

Platforms: darwin
Maintainers: mich@freebsdcluster.org
</code></pre>
<p>Usage context: When you work on auto-setup of new projects (say, making your simplification pipeline even simpler) you can use rpl on configuration files, say, and have non-conflicting markers like MEGASKULLYOUR\_PROJECT_NAMEMEGASKULL which would be replaced by your configuration strings.</p>
<p>Or, when you find a new name for something, and just need to try out this tool</p>
<p><strong>Update</strong>: got it to work with sed, which is everywhere. The machine I worked on had FreeBSD, but the port command didn&#8217;t answer.</p>
<pre><code>
  sed -e 's/max_preview_size = 262144/max_preview_size = 10000000/g' -i boook trac.ini
</code></pre>
<p>A breakdown, dear reader:</p>
<p><code>-e</code> means add a command. <code>s</code> is for substitution of one sequence for another. <code>g</code> is for globally in given files, it could also be a number, say 1, meaning &#8220;replace match number 1&#8243;.</p>
<p><code>-i</code> means &#8220;irritatingly in-place editing&#8221;</p>
<p><code>-i boook</code> means &#8220;&#8230;and since it is irritating, add the backup file trac.ini.boook as it were before those edits, to not annoy more than necessary&#8221;</p>
<p>[tags]textprocessing,unix[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://ollehost.dk/blog/2007/05/07/unix-search-and-replace-rpl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List outdated port names with awk</title>
		<link>http://ollehost.dk/blog/2007/04/26/list-outdated-port-names-with-awk/</link>
		<comments>http://ollehost.dk/blog/2007/04/26/list-outdated-port-names-with-awk/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 08:51:01 +0000</pubDate>
		<dc:creator>olleolleolle</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://ollehost.dk/blog/?p=341</guid>
		<description><![CDATA[MacPorts. Sometimes your ports are outdated. There&#8217;s a pseudo-portname for them. The report has many columns. And I only want the names, not their versions. port list outdated &#124; awk 'BEGIN { RS="\n" } { print $1 }' > names_of_old_ports.txt &#8230; <a href="http://ollehost.dk/blog/2007/04/26/list-outdated-port-names-with-awk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>MacPorts. Sometimes your ports are outdated. There&#8217;s a pseudo-portname for them. The report has many columns. And I only want the names, not their versions.</p>
<pre><code>
port list outdated | awk 'BEGIN { RS="\n" } { print $1 }' > names_of_old_ports.txt
</code></pre>
<p>Done.</p>
<p>Update: got a bug, fixed it. Sheesh.</p>
<p>[tags]awk,unix[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://ollehost.dk/blog/2007/04/26/list-outdated-port-names-with-awk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snippet: remove .svn directories</title>
		<link>http://ollehost.dk/blog/2006/08/27/snippet-remove-svn-directories/</link>
		<comments>http://ollehost.dk/blog/2006/08/27/snippet-remove-svn-directories/#comments</comments>
		<pubDate>Sun, 27 Aug 2006 07:25:08 +0000</pubDate>
		<dc:creator>Olle Jonsson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://olle.ter.dk/blog/?p=289</guid>
		<description><![CDATA[Snippet to recursively drop Subversion control of a directory. It removes the .svn directories, and their contents. find . -name ".svn" -exec rm -rf {} \; Credit: Zed Shaw, at the Mongrel mailing list. (Note to contemporary readers: Crazy old &#8230; <a href="http://ollehost.dk/blog/2006/08/27/snippet-remove-svn-directories/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Snippet to recursively drop Subversion control of a directory. It removes the .svn directories, and their contents.</p>
<p><code>  find . -name ".svn" -exec rm -rf {} \;</code></p>
<p>Credit: Zed Shaw, at the Mongrel mailing list.</p>
<p>(Note to contemporary readers: Crazy old info) Oh, and if you are using Mongrel, and need help with it, there is a new chatroom at <a href="http://www.lingr.com/room/3yXhqKbfPy8" title="Official help chatroom for Mongrel">http://www.lingr.com/room/3yXhqKbfPy8</a>, where Zed, the developer, hangs out.</p>
<p>[tags]unix,subversion,snippets[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://ollehost.dk/blog/2006/08/27/snippet-remove-svn-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash functions example</title>
		<link>http://ollehost.dk/blog/2006/07/26/bash-functions-example/</link>
		<comments>http://ollehost.dk/blog/2006/07/26/bash-functions-example/#comments</comments>
		<pubDate>Wed, 26 Jul 2006 09:06:23 +0000</pubDate>
		<dc:creator>Olle Jonsson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://olle.ter.dk/blog/?p=283</guid>
		<description><![CDATA[Bradley Taylor (of [Railsmachine](http://railsmachine.com/) hosting fame) said this on [the excellent Mongrel mailing list](http://rubyforge.org/mailman/listinfo/mongrel-users): &#8220;Just use these bash functions and put them in your .bashrc:&#8221; cluster\_restart () { mongrel\_rails cluster::restart -C /etc/ mongrel\_cluster/$1.yml; } cluster\_start () { mongrel\_rails cluster::start -C &#8230; <a href="http://ollehost.dk/blog/2006/07/26/bash-functions-example/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Bradley Taylor (of [Railsmachine](http://railsmachine.com/) hosting fame) said this on [the excellent Mongrel mailing list](http://rubyforge.org/mailman/listinfo/mongrel-users):</p>
<p>&#8220;Just use these bash functions and put them in your <code>.bashrc</code>:&#8221;</p>
<p><code>
<pre>
  cluster\_restart () {
	mongrel\_rails cluster::restart -C /etc/ mongrel\_cluster/$1.yml;
  }
  cluster\_start () {
	mongrel\_rails cluster::start -C /etc/ mongrel\_cluster/$1.yml;
  }
  cluster\_stop () {
	mongrel\_rails cluster::stop -C /etc/mongrel\_cluster/$1.yml;
  }

  usage:
  $ cluster_start fluxura
</pre>
<p></code><br />
([See the thread in the archives](http://rubyforge.org/pipermail/mongrel-users/2006-July/000780.html).)</p>
<p>That is, when someone asked about if it wasn&#8217;t possible to just have a command, and that it&#8217;d be cool if Mongrel had such a simple command, he shows code.</p>
<p>Also, the example&#8217;s great. </p>
<p>* The <code>$1</code> to access the first argument to the function call, and that<br />
* you don&#8217;t need to put in any parameter lists in the functions, and that<br />
* its control structures looks mostly like any C-like language.</p>
<p>I feel kickstarted by this. Thanks, Bradley.</p>
<p>[tags]bash,unix[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://ollehost.dk/blog/2006/07/26/bash-functions-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awk, text processing</title>
		<link>http://ollehost.dk/blog/2006/07/19/awk-text-processing/</link>
		<comments>http://ollehost.dk/blog/2006/07/19/awk-text-processing/#comments</comments>
		<pubDate>Wed, 19 Jul 2006 15:06:02 +0000</pubDate>
		<dc:creator>olleolleolle</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://olle.ter.dk/blog/?p=281</guid>
		<description><![CDATA[Fooling around with load average output on a shared host (where it can be life-or-death): $ w -s&#124;awk '/load average:/ { print "Load averages:\nPast 1 min: " $10 "\nPast 5 min: " $11 "\nPast 15 min: " $12 }' Load &#8230; <a href="http://ollehost.dk/blog/2006/07/19/awk-text-processing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Fooling around with load average output on a shared host (where it can be life-or-death):</p>
<pre style="overflow:auto;"><code style="font-size:85%;font-family:arial;">
$ w -s|awk '/load average:/ { print "Load averages:\nPast 1 min:  " $10 "\nPast 5 min:  " $11 "\nPast 15 min: " $12 }'
Load averages:
Past 1 min:  20.94,
Past 5 min:  20.67,
Past 15 min: 18.75
</code></pre>
<p>What&#8217;s w, you say? The manpage says:</p>
<p>> w &#8211; Show who is logged on and what they are doing.</p>
<p>Awk&#8217;s got grep rolled right into it. And the default action is &#8220;print the line&#8221;. Practical. (Above I had to go all fancy, and adding what those fields mean. Sorry about that. I&#8217;m like that.)</p>
<p>If you scroll a bit in the little code window above, you&#8217;ll see that the significant values are $10, $11, and $12. The tenth, eleventh, and twelvth *words*! If your data is tab-separated, you change the delimiter to a tab instead. Or, to a comma for CSV files. Bam, you can read almost anything right there. </p>
<p>The concatenation (fancy word for adding two strings to one) sign is&#8230; nothing. Elegant.</p>
<p>Read more on awk in [the gawk manual (Free documentation!)](http://www.cs.utah.edu/dept/old/texinfo/gawk/gawk_toc.html).</p>
<p>**Update**: Or, read esr&#8217;s [damning of awk](http://www.faqs.org/docs/artu/ch08s02.html#awk), in his [The Art of Unix Programming](http://www.faqs.org/docs/artu/).</p>
]]></content:encoded>
			<wfw:commentRss>http://ollehost.dk/blog/2006/07/19/awk-text-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

