<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8626864186639597116</id><updated>2024-09-05T03:27:31.402-07:00</updated><title type='text'>Troll Island</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8626864186639597116.post-1839541432922535221</id><published>2009-06-07T11:04:00.000-07:00</published><updated>2009-06-07T15:31:03.227-07:00</updated><title type='text'>Search for a range of lines</title><content type='html'>&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div class=&quot;codesegment&quot;&gt;
&lt;pre&gt;&lt;code&gt;
# Use awk&#39;s range operator, a comma, to print an entire
# function definition in an init script

awk &#39;/action\(\) {/ , /}/&#39; /etc/init.d/functions
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;pre&gt;&lt;code&gt;
    action() {
      local STRING rc

      STRING=$1
      echo -n &quot;$STRING &quot;
      shift
      &quot;$@&quot; &amp;&amp; success $&quot;$STRING&quot; || failure $&quot;$STRING&quot;
      rc=$?
      echo
      return $rc
    }
&lt;/code&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/1839541432922535221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://trollisland.blogspot.com/2009/06/search-range-of-lines.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/1839541432922535221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/1839541432922535221'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/2009/06/search-range-of-lines.html' title='Search for a range of lines'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8626864186639597116.post-535994100402610700</id><published>2009-05-21T18:46:00.000-07:00</published><updated>2009-05-21T19:34:59.074-07:00</updated><title type='text'>Get the directory of the currently running script</title><content type='html'>&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div class=&quot;codesegment&quot;&gt;
&lt;pre&gt;&lt;code&gt;
# $0 gives the relative path the script was invoked with, so:
#    ./script.sh gives ./script.sh
#    ~/script.sh gives /home/user/script.sh
#
# $(pwd) prints the working directory, not the script file location
#
# `which $0` is a special use to get the full path and name of the script
# Called this way, which does not do its normal search of $PATH
#
# Enclose in double quotes to account for folders with spaces in them

  RUNDIR=$(dirname &quot;$(which &quot;$0&quot;)&quot;)

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/535994100402610700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://trollisland.blogspot.com/2009/05/get-directory-of-currently-running.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/535994100402610700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/535994100402610700'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/2009/05/get-directory-of-currently-running.html' title='Get the directory of the currently running script'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8626864186639597116.post-7438052252805207438</id><published>2009-05-21T18:31:00.000-07:00</published><updated>2009-05-21T19:15:37.337-07:00</updated><title type='text'>Override noclobber</title><content type='html'>&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div class=&quot;codesegment&quot;&gt;
&lt;pre&gt;&lt;code&gt;
set -o noclobber
echo &quot;test&quot; &gt; test.txt
echo &quot;test&quot; &gt; test.txt 
# bash: test.txt: cannot overwrite existing file

echo &quot;test&quot; &gt;| test.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/7438052252805207438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://trollisland.blogspot.com/2009/05/override-noclobber.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/7438052252805207438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/7438052252805207438'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/2009/05/override-noclobber.html' title='Override noclobber'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8626864186639597116.post-5170470513899422723</id><published>2009-05-21T17:55:00.000-07:00</published><updated>2009-05-21T19:36:11.321-07:00</updated><title type='text'>Variable length expansion</title><content type='html'>&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div class=&quot;codesegment&quot;&gt;
&lt;pre&gt;&lt;code&gt;
# How many characters are in variable XYZ?

  XYZ=&quot;12345&quot;
  echo ${#XYZ}

# How many parameters did you feed me?

  function howmany ()
  {
    echo ${#@}
  }

  howmany 1 2 3 4 5 6789

# How many elements are in array XYZ?

  XYZ=( 1 2 3 4 5 6 7)
  echo ${#XYZ[@]}

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/5170470513899422723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://trollisland.blogspot.com/2009/05/variable-length-expansion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/5170470513899422723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/5170470513899422723'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/2009/05/variable-length-expansion.html' title='Variable length expansion'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8626864186639597116.post-3101215551264434572</id><published>2009-05-05T14:06:00.001-07:00</published><updated>2009-05-05T14:14:57.318-07:00</updated><title type='text'>Is this an integer?</title><content type='html'>&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div class=&quot;codesegment&quot;&gt;
&lt;pre&gt;&lt;code&gt;
function isInteger ()
{
  echo &quot;$@&quot; | grep -q -v &quot;[^-0-9]&quot;
}

if isInteger 1975; then echo &quot;Yes, that is an integer&quot;; fi
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;br&gt;

Yes, that is an integer</content><link rel='replies' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/3101215551264434572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://trollisland.blogspot.com/2009/05/is-this-integer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/3101215551264434572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/3101215551264434572'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/2009/05/is-this-integer.html' title='Is this an integer?'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8626864186639597116.post-394178031049973179</id><published>2009-05-03T16:55:00.000-07:00</published><updated>2009-05-03T17:54:30.392-07:00</updated><title type='text'>Instant HTTP Server</title><content type='html'>Starts a web server on port 8000 and serves up the current directory:

&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div class=&quot;codesegment&quot;&gt;
&lt;pre&gt;&lt;code&gt;
python -m SimpleHTTPServer
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;br&gt;
Scary? Damn straight.</content><link rel='replies' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/394178031049973179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://trollisland.blogspot.com/2009/05/instant-http-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/394178031049973179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/394178031049973179'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/2009/05/instant-http-server.html' title='Instant HTTP Server'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8626864186639597116.post-5319164075383110693</id><published>2009-05-03T15:27:00.000-07:00</published><updated>2009-05-03T17:50:51.061-07:00</updated><title type='text'>Get the network ID from an IP address and subnet mask</title><content type='html'>&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div class=&quot;codesegment&quot;&gt;
&lt;pre&gt;&lt;code&gt;
echo &quot;192.168.5.133 255.255.255.250&quot; | \
awk &#39;BEGIN {FS=&quot;[. ]&quot;; OFS=&quot;.&quot;} {print and($1,$5), and($2,$6), and($3,$5), and($4,$8)}&#39;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;br&gt;&lt;code&gt;192.168.5.128&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://trollisland.blogspot.com/feeds/5319164075383110693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://trollisland.blogspot.com/2009/05/network-id-from-ip.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/5319164075383110693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8626864186639597116/posts/default/5319164075383110693'/><link rel='alternate' type='text/html' href='http://trollisland.blogspot.com/2009/05/network-id-from-ip.html' title='Get the network ID from an IP address and subnet mask'/><author><name>Robert Patton</name><uri>http://www.blogger.com/profile/09699729758385238019</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>