<?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>anatexis.net</title>
	<atom:link href="http://anatexis.net/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://anatexis.net/wordpress</link>
	<description>random notes doing stuff with electronics and linux</description>
	<lastBuildDate>Wed, 02 May 2012 13:52:28 +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>When ruby has problems with libraries</title>
		<link>http://anatexis.net/wordpress/?p=63&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=when-ruby-has-problems-with-libraries</link>
		<comments>http://anatexis.net/wordpress/?p=63#comments</comments>
		<pubDate>Wed, 02 May 2012 13:50:30 +0000</pubDate>
		<dc:creator>jlovick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=63</guid>
		<description><![CDATA[when you start getting errors like this you know something is messed up. /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': libruby19.so.1.9: cannot open shared object file: No such file or directory - /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/narray.so (LoadError) from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from ./image_stack.rb:8:in `' now one might be forgiven in thinking that this means that ruby cant find the file narray.so but this isnt [...]]]></description>
			<content:encoded><![CDATA[<p>when you start getting errors like this you know something is messed up. <img src='http://anatexis.net/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<pre>
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': libruby19.so.1.9: cannot open shared object file: No such file or directory - /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/narray.so (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from ./image_stack.rb:8:in `'
</pre>
<p><span id="more-63"></span><br />
now one might be forgiven in thinking that this means that ruby cant find the file
<pre> <b> narray.so </b> </pre>
<p> but this isnt actually the case. </p>
<pre>
ldd /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/narray.so
        linux-vdso.so.1 =>  (0x00007fff82bff000
        libruby19.so.1.9 => not found
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f65c7b1c000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f65c775e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f65c805a000)
</pre>
<p>so next thing to do is to look to see if you have a libruby19.so.1.9 somewhere on your system </p>
<pre>
 >locate libruby19.so.1.9
</pre>
<p>in my case the answer was <b>no</b>, when a library is missing the first place it looks to find it is the current directory, so instead of adding complication in the
<pre>/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ </pre>
<p> directory. i just made a link </p>
<pre>
cd /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/
ln -s /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/libruby.so.1.9.1 ./libruby19.so.1.9
ldd ./narray.so
        linux-vdso.so.1 =>  (0x00007fff8c3ff000)
        libruby19.so.1.9 => /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/libruby19.so.1.9 (0x00007f7411580000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7411275000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7410eb7000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7410c9a000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7410a92000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f741088d000)
        libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f7410654000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f7411bef000)
</pre>
<p>which fixed my issues, now why narray didnt use the right name the lib in the first place i dont know&#8230;. </p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=63</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>when grub rescue strikes</title>
		<link>http://anatexis.net/wordpress/?p=53&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=when-grub-rescue-strikes</link>
		<comments>http://anatexis.net/wordpress/?p=53#comments</comments>
		<pubDate>Fri, 27 Apr 2012 08:35:28 +0000</pubDate>
		<dc:creator>jlovick</dc:creator>
				<category><![CDATA[grub]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=53</guid>
		<description><![CDATA[When converting a virtualbox virtual machine from gentoo to ubuntu, i ran into the issue that grub had not installed itself correctly, leaving me a prompt grub rescue&#62; which is not the most helpful of prompts in the world&#8230; first of all, find your disk ls it&#8217;ll look like (hdx,y) but perhaps the ,y wont [...]]]></description>
			<content:encoded><![CDATA[<p>When converting a virtualbox virtual machine from gentoo to ubuntu, i ran into the issue that grub had not installed itself correctly,<br />
leaving me a prompt</p>
<pre><strong>grub rescue&gt;</strong></pre>
<p>which is not the most helpful of prompts in the world&#8230; <img src='http://anatexis.net/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
<span id="more-53"></span><br />
first of all, find your disk</p>
<pre><strong>ls</strong></pre>
<p>it&#8217;ll look like (hdx,y)<br />
but perhaps the
<pre><strong> ,y </strong></pre>
<p> wont be visible.<br />
if so try a
<pre><strong> 1</strong> </pre>
<pre><strong>set prefix=(hd0,1)/grub</strong></pre>
<p>then try</p>
<pre><strong>insmod (hd0,1)/grub/linux.mod</strong></pre>
<p>if that works try adding in a coupld more modules</p>
<pre><strong> insmod ext2.mod</strong> </pre>
<pre><strong> insmod gzio.mod </strong></pre>
<p>OK all looks good at this stage i hope.<br />
now were are in grub2 so make sure to set</p>
<pre>
<strong>set root=(hd0,1)
set prefix=(hd0,1)/grub </strong></pre>
<p>use
<pre><strong> ls </strong></pre>
<p>to find out the name of your initrd and vmlinuz files</p>
<pre>
<strong>linux /boot/vmlinuz-3.0.0-1 root=/dev/sda3 ro
initrd /boot/initrd.img-3.0.0-1
boot</strong>
</pre>
<p>and then voilia it should boot appropriately. then rerun grub-setup</p>
<p>source for this came from  <a href="http://karuppuswamy.com/wordpress/2011/09/09/how-to-fix-grub-rescue-prompt-without-live-cd-for-grub2/" title="how-to-fix-grub" target="_blank"> how to fix grub </a><br />
Another good resource for grub is <a href="http://ubuntuforums.org/showthread.php?t=1195275" title="grub resource">Ubuntu grub resource</a></p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=53</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rsync style remote transfer without the overhead for lots of little files</title>
		<link>http://anatexis.net/wordpress/?p=45&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rsync-style-remote-transfer-without-the-overhead-for-lots-of-little-files</link>
		<comments>http://anatexis.net/wordpress/?p=45#comments</comments>
		<pubDate>Sat, 14 Apr 2012 00:00:00 +0000</pubDate>
		<dc:creator>jlovick</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=45</guid>
		<description><![CDATA[Using a little bit of RUBY its possible to make a quick and dirty replacement for rsync that instead uses ssh and tar. for efficient transfer of lots of files. begin location = "Klyuchevskoy" local_prefix = "/depot/webcams/from_kasatochi/" command_remote="ssh -p 2222 anatexis.net 'find /export/whale/webcam-data/#{location}/*' &#124; sed 's#/export/whale/webcam-data/##g' &#124; grep jpeg &#62; gorilla-filelist.txt" command_local="find /depot/webcams/from_kasatochi/#{location}/* &#124; sed [...]]]></description>
			<content:encoded><![CDATA[<p>Using a little bit of RUBY its possible to make a quick and dirty replacement for rsync that instead uses ssh and tar. for efficient transfer of lots of files.</p>
<pre>
begin
 location = "Klyuchevskoy"
 local_prefix = "/depot/webcams/from_kasatochi/"
 command_remote="ssh -p 2222 anatexis.net 'find /export/whale/webcam-data/#{location}/*' | sed 's#/export/whale/webcam-data/##g' | grep jpeg &gt; gorilla-filelist.txt"
 command_local="find /depot/webcams/from_kasatochi/#{location}/* | sed 's\##{local_prefix}\#\#g' | grep jpeg &gt; local-filelist.txt"
 system(command_remote)
 system(command_local)
 puts " reading "
 gorilla = File.open('gorilla-filelist.txt', 'rb') { |file| file.read }
 puts "read gorilla"
 local = File.open('local-filelist.txt', 'rb') { |file| file.read }
 puts "read local"
 set_gorilla = gorilla.split("\n")
 set_local = local.split("\n")
 puts set_gorilla.count
 puts set_local.count
 set_final = set_local - set_gorilla
 puts set_final.count
 newFile = File.open("./tar-filelist.txt", "w")
 set_final.each { |item|
 newFile.puts "./#{item}"
 }
 pwd=(%x[pwd]).chomp
 final_command="cd #{local_prefix} &amp;&amp; tar --files-from=#{pwd}/tar-filelist.txt -vzc | ssh -p2222 anatexis.net 'tar -vxz -C/export/whale/webcam-data/'"
 puts final_command
 system(final_command)
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=45</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>getting svn out of there</title>
		<link>http://anatexis.net/wordpress/?p=41&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-svn-out-of-there</link>
		<comments>http://anatexis.net/wordpress/?p=41#comments</comments>
		<pubDate>Wed, 14 Mar 2012 20:23:41 +0000</pubDate>
		<dc:creator>jlovick</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=41</guid>
		<description><![CDATA[i recently needed to get all of the svn junk out of a repo so that i could just work with a clean directory structure etc find ./* &#124; grep  svn &#62; exclude.txt tar cv --file=proj.tar  --exclude-from=./exclude.txt ./trunk ﻿ did the job nicely]]></description>
			<content:encoded><![CDATA[<p>i recently needed to get all of the svn junk out of a repo so that i could just work with a clean directory structure etc</p>
<pre>
find ./* | grep  svn &gt; exclude.txt
tar cv --file=proj.tar  --exclude-from=./exclude.txt ./trunk
</pre>
<p>﻿<br />
did the job nicely</p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=41</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recent projects</title>
		<link>http://anatexis.net/wordpress/?p=38&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=recent-projects</link>
		<comments>http://anatexis.net/wordpress/?p=38#comments</comments>
		<pubDate>Sat, 21 Aug 2010 04:00:54 +0000</pubDate>
		<dc:creator>jlovick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=38</guid>
		<description><![CDATA[Been playing with prototype and jQuery, they both like to use $ to invoke them but after rewriting a couple of trivial plugins I have jQuery doing what I need. I do like the way prototype extends JavaScript. In ruby I have begun to use 1.9 getting ubuntu to automatically use 1.9 instead of 1.8 [...]]]></description>
			<content:encoded><![CDATA[<p>Been playing with prototype and jQuery, they both like to use $ to invoke them but after rewriting a couple of trivial plugins I have jQuery doing what I need. I do like the way prototype extends JavaScript. </p>
<p>In ruby I have begun to use 1.9 getting ubuntu to automatically use 1.9 instead of 1.8 has been an issue, as has incompatible gems.  Next I want to play with ruby waves, a rails alternative. </p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=38</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fighting with routers</title>
		<link>http://anatexis.net/wordpress/?p=37&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fighting-with-routers</link>
		<comments>http://anatexis.net/wordpress/?p=37#comments</comments>
		<pubDate>Wed, 21 Apr 2010 00:18:38 +0000</pubDate>
		<dc:creator>jlovick</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[dd-wrt]]></category>
		<category><![CDATA[linksys]]></category>
		<category><![CDATA[wrt54]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=37</guid>
		<description><![CDATA[So we have a simple network here, three floors to the house so three wireless routers. All linked together via wifi. Or at least that was the case til a power cut washed away the settings of the main gateway router connected to the dsl. No matter what I did, I couldn&#8217;t get them all [...]]]></description>
			<content:encoded><![CDATA[<p>So we have a simple network here, three floors to the house so three wireless routers. </p>
<p>All linked together via wifi.  Or at least that was the case til a power cut washed away the settings of the main gateway router connected to the dsl. </p>
<p>No matter what I did, I couldn&#8217;t get them all talking to each again. Restoring the settings backup didn&#8217;t work either.  So I figured I would update it to the latest dd-wrt firmware, a day of playing at tftp and repeated reflashings later I went from having a linksys wrt54 brick to having a working router.</p>
<p>Now I used to do the networking over wds but I soon discovered that you need the same firmware version on every router, this wasn&#8217;t the case before, I guess I was just lucky. </p>
<p>A day later and now I have 3 routers all with the latest dd-wrt firmware.  But can I get wds going stabely no! By now I am a little frustrated so I gave up with getting wds to work and am now just using client bridging, no range increase for the wifi, but atleast it seems stable.   </p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=37</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>some great sed one liners</title>
		<link>http://anatexis.net/wordpress/?p=28&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=some-great-sed-one-liners</link>
		<comments>http://anatexis.net/wordpress/?p=28#comments</comments>
		<pubDate>Tue, 23 Feb 2010 19:53:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=28</guid>
		<description><![CDATA[i found this here http://www.unixguide.net/unix/sedoneliner.shtml HANDY ONE-LINERS FOR SED (Unix stream editor) Oct. 29, 1997 compiled by Eric Pement version 4.3 Latest version of this file is always at FILE SPACING: # double space a file sed G # triple space a file sed 'G;G' # undo double-spacing (assumes even-numbered lines are always blank) sed [...]]]></description>
			<content:encoded><![CDATA[<p>i found this here http://www.unixguide.net/unix/sedoneliner.shtml</p>
<p>HANDY ONE-LINERS FOR SED (Unix stream editor) Oct. 29, 1997<br />
compiled by Eric Pement <epement@jpusa.chi.il.us> version 4.3<br />
Latest version of this file is always at  <http://www.wollery.demon.co.uk></p>
<p><span id="more-28"></span></p>
<h2>FILE SPACING:</h2>
<p># double space a file</p>
<pre>sed G</pre>
<p># triple space a file</p>
<pre>sed 'G;G'</pre>
<p># undo double-spacing (assumes even-numbered lines are always  blank)</p>
<pre>sed 'n;d'</pre>
<h2>NUMBERING:</h2>
<p># number each line of a file (simple left alignment). Using a tab  (see<br />
# note on &#8216;\t&#8217; at end of file) instead of space will preserve  margins.</p>
<pre>sed = filename | sed 'N;s/\n/\t/'</pre>
<p># number each line of a file (number on left, right-aligned)</p>
<pre>sed = filename | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'</pre>
<p># number each line of file, but only print numbers if line is not  blank</p>
<pre>sed '/./=' filename | sed '/./N; s/\n/ /'</pre>
<p># count lines (emulates &#8220;wc -l&#8221;)</p>
<pre>sed -n '$='</pre>
<h2>TEXT CONVERSION AND SUBSTITUTION:</h2>
<p># IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix  format</p>
<pre>sed 's/.$//'</pre>
<p># IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format</p>
<pre>sed 's/$//' # method 1</pre>
<pre>sed -n p # method 2</pre>
<p># delete leading whitespace (spaces, tabs) from front of each  line<br />
# aligns all text flush left</p>
<pre>sed 's/^[ \t]*//' # see note on '\t' at end of file</pre>
<p># delete trailing whitespace (spaces, tabs) from end of each line</p>
<pre>sed 's/[ \t]*$//' # see note on '\t' at end of file</pre>
<p># delete BOTH leading and trailing whitespace from each line</p>
<pre>sed 's/^[ \t]*//;s/[ \t]*$//'</pre>
<p># insert 5 blank spaces at beginning of each line (make page  offset)</p>
<pre>sed 's/^/ /'</pre>
<p># align all text flush right on a 79-column width</p>
<pre>sed -e :a -e 's/^.\{1,78\}$/ &#038;/;ta' # set at 78 plus 1 space</pre>
<p># center all text in the middle of 79-column width. In method 1,<br />
# spaces at the beginning of the line are significant, and trailing<br />
# spaces are appended at the end of the line. In method 2, spaces at<br />
# the beginning of the line are discarded in centering the line, and<br />
# no trailing spaces appear at the end of lines.</p>
<pre>sed -e :a -e 's/^.\{1,77\}$/ &#038; /;ta' # method 1</pre>
<pre>sed -e :a -e 's/^.\{1,77\}$/ &#038;/;ta' -e 's/\( *\)\1/\1/' # method 2</pre>
<p># substitute (find &#038; replace) &#8220;foo&#8221; with &#8220;bar&#8221; on each line</p>
<pre>sed 's/foo/bar/' # replaces only 1st instance in a line</pre>
<pre>sed 's/foo/bar/4' # replaces only 4th instance in a line</pre>
<pre>sed 's/foo/bar/g' # replaces ALL instances in a line</pre>
<p># substitute &#8220;foo&#8221; with &#8220;bar&#8221; ONLY for lines which contain &#8220;baz&#8221;</p>
<pre>sed '/baz/s/foo/bar/g'</pre>
<p># substitute &#8220;foo&#8221; with &#8220;bar&#8221; EXCEPT for lines which contain  &#8220;baz&#8221;</p>
<pre>sed '/baz/!s/foo/bar/g'</pre>
<p># reverse order of lines (emulates &#8220;tac&#8221;)</p>
<pre>sed '1!G;h;$!d'</pre>
<p># reverse each character on the line (emulates &#8220;rev&#8221;)</p>
<pre>sed '/\n/!G;s/\(.\)\(.*\n\)/&#038;\2\1/;//D;s/.//'</pre>
<p># join pairs of lines side-by-side (like &#8220;paste&#8221;)</p>
<pre>sed 'N;s/\n/ /'</pre>
<h2>SELECTIVE PRINTING OF CERTAIN LINES:</h2>
<p># print first 10 lines of file (emulates behavior of &#8220;head&#8221;)</p>
<pre>sed 10q</pre>
<p># print first line of file (emulates &#8220;head -1&#8243;)</p>
<pre>sed q</pre>
<p># print last 10 lines of file (emulates &#8220;tail&#8221;)</p>
<pre>sed -e :a -e '$q;N;11,$D;ba'</pre>
<p># print last line of file (emulates &#8220;tail -1&#8243;)</p>
<pre>sed '$!d'</pre>
<p># print only lines which match regular expression (emulates  &#8220;grep&#8221;)</p>
<pre>sed -n '/regexp/p' # method 1</pre>
<pre>sed '/regexp/!d' # method 2</pre>
<p># print only lines which do NOT match regexp (emulates &#8220;grep -v&#8221;)</p>
<pre>sed -n '/regexp/!p' # method 1, corresponds to above</pre>
<pre>sed '/regexp/d' # method 2, simpler syntax</pre>
<p># print 1 line of context before and after regexp, with line  number<br />
# indicating where the regexp occurred (similar to &#8220;grep -A1 -B1&#8243;)</p>
<pre>sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h</pre>
<p># grep for AAA and BBB and CCC (in any order)</p>
<pre>sed '/AAA/!d; /BBB/!d; /CCC/!d'</pre>
<p># grep for AAA or BBB or CCC (emulates &#8220;egrep&#8221;)</p>
<pre>sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d</pre>
<p># print only lines of 65 characters or longer</p>
<pre>sed -n '/^.\{65\}/p'</pre>
<p># print only lines of less than 65 characters</p>
<pre>sed -n '/^.\{65\}/!p' # method 1, corresponds to above</pre>
<pre>sed '/^.\{65\}/d' # method 2, simpler syntax</pre>
<p># print section of file from regular expression to end of file</p>
<pre>sed -n '/regexp/,$p'</pre>
<p># print section of file based on line numbers (lines 8-12,  inclusive)</p>
<pre>sed -n '8,12p' # method 1</pre>
<pre>sed '8,12!d' # method 2</pre>
<p># print line number 52</p>
<pre>sed -n '52p' # method 1</pre>
<pre>sed '52!d' # method 2</pre>
<pre>sed '52q;d' # method 3, efficient on large files</pre>
<p># print section of file between two regular expressions  (inclusive)</p>
<pre>sed -n '/Iowa/,/Montana/p' # case sensitive</pre>
<h2>SELECTIVE DELETION OF CERTAIN LINES:</h2>
<p># print all of file EXCEPT section between 2 regular expressions</p>
<pre>sed '/Iowa/,/Montana/d'</pre>
<p># delete duplicate lines from a sorted file (emulates &#8220;uniq&#8221;).  First<br />
# line in a set of duplicate lines is kept, the rest are deleted</p>
<pre>sed '$!N; /^\(.*\)\n\1$/!P; D'</pre>
<p># delete ALL blank lines from a file (same as &#8220;grep &#8216;.&#8217; &#8220;)</p>
<pre>sed '/^$/d'</pre>
<p># delete all CONSECUTIVE blank lines from file except the first;  also<br />
# deletes all blank lines from top and end of file (emulates &#8220;cat  -s&#8221;)</p>
<pre>sed '/./,/^$/!d' # method 1, allows 0 blanks at top, 1 at EOF</pre>
<pre>sed '/^$/N;/\n$/D' # method 2, allows 1 blank at top, 0 at EOF</pre>
<p># delete all CONSECUTIVE blank lines from file except the first  2:</p>
<pre>sed '/^$/N;/\n$/N;//D'</pre>
<p># delete all leading blank lines at top of file</p>
<pre>sed '/./,$!d'</pre>
<p># delete all trailing blank lines at end of file</p>
<pre>sed -e :a -e '/^\n*$/N;/\n$/ba'</pre>
<h2>SPECIAL APPLICATIONS:</h2>
<p># remove nroff overstrikes (char, backspace) from man pages</p>
<pre>sed "s/.`echo \\\b`//g" # double quotes required for Unix  environment</pre>
<pre>sed 's/.\x08//g' # hex expression for GNU sed (octal is "\010")</pre>
<p># get Usenet/e-mail message header</p>
<pre>sed '/^$/q' # deletes everything after first blank line</pre>
<p># get Usenet/e-mail message body</p>
<pre>sed '1,/^$/d' # deletes everything up to first blank line</pre>
<p># get Subject header, but remove initial &#8220;Subject: &#8221; portion</p>
<pre>sed '/^Subject: */!d; s///;q'</pre>
<p># get return address header</p>
<pre>sed '/^Reply-To:/q; /^From:/h; /./d;g;q'</pre>
<p># parse out the address proper. Pulls out the e-mail address by  itself<br />
# from the 1-line return address header (see preceding script)</p>
<pre>sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//'</pre>
<p># add a leading angle bracket and space to each line (quote a  message)</p>
<pre>sed 's/^/> /</pre>
<p># delete leading angle bracket &#038; space from each line  (unquote a message)</p>
<pre>sed 's/^> //'</pre>
<p># remove most HTML tags (accommodates multiple-line tags)</p>
<pre>sed -e :a -e 's/<[^<]*>/ /g;/</{N;s/\n/ /;ba;}'</pre>
<p># extract multi-part uuencoded binaries, removing extraneous  header<br />
# info, so that only the uuencoded portion remains. Files passed to<br />
# sed must be passed in the proper order. Version 1 can be entered<br />
# from the command line; version 2 can be made into an executable<br />
# Unix shell script. (Modified from a script by Rahul Dhesi.)</p>
<pre>sed '/^end/,/^begin/d' file1 file2 ... fileX | uudecode # vers. 1</pre>
<pre>sed '/^end/,/^begin/d' $* | uudecode # vers. 2</pre>
<p># zip up each .TXT file individually, deleting the source file  and<br />
# setting the name of each .ZIP file to the basename of the .TXT  file<br />
# (under DOS: the "dir /b" switch returns bare filenames in all  caps).</p>
<pre>echo @echo off >zipup.bat</pre>
<pre>dir /b *.txt | sed "s/^\(.*\)\.TXT/pkzip -mo \1 \1.TXT/"  >>zipup.bat</pre>
<h2>TYPICAL USE:</h2>
<p>Sed takes one or more editing commands and applies  all of<br />
them, in sequence, to each line of input. After all the commands  have<br />
been applied to the first input line, that line is output and a  second<br />
input line is taken for processing, and the cycle repeats. The<br />
preceding examples assume that input comes from the standard input<br />
device (i.e, the console, normally this will be piped input). One or<br />
more filenames can be appended to the command line if the input does<br />
not come from stdin. Output is sent to stdout (the screen). Thus:</p>
<pre>cat filename | sed '10q' # uses piped input
sed '10q' filename # same effect, avoids a useless "cat"
sed '10q' filename > newfile # redirects output to disk</pre>
<p>For additional syntax instructions, including the way to apply  editing<br />
commands from a disk file instead of the command line, consult "sed &#038;<br />
awk, 2nd Edition," by Dale Dougherty and Arnold Robbins (O'Reilly,<br />
1997; http://www.ora.com), "UNIX Text Processing," by Dale Dougherty<br />
and Tim O'Reilly (Hayden Books, 1987) or the tutorials by Mike Arst<br />
distributed in U-SEDIT2.ZIP (many sites). To fully exploit the power<br />
of sed, one must understand "regular expressions." For this, see<br />
"Mastering Regular Expressions" by Jeffrey Friedl (O'Reilly, 1997).<br />
The manual ("man") pages on Unix systems may be helpful (try "man<br />
sed", "man regexp", or the subsection on regular expressions in "man<br />
ed"), but man pages are notoriously difficult. They are not written to<br />
teach sed use or regexps to first-time users, but as a reference  text<br />
for those already acquainted with these tools.</p>
<h2>QUOTING SYNTAX:</h2>
<p>The preceding examples use single quotes ('...')<br />
instead of double quotes ("...") to enclose editing commands, since<br />
sed is typically used on a Unix platform. Single quotes prevent the<br />
Unix shell from intrepreting the dollar sign ($) and backquotes<br />
(`...`), which are expanded by the shell if they are enclosed in<br />
double quotes. Users of the "csh" shell and derivatives will also  need<br />
to quote the exclamation mark (!) with the backslash (i.e., \!) to<br />
properly run the examples listed above, even within single quotes.<br />
Versions of sed written for DOS invariably require double quotes<br />
("...") instead of single quotes to enclose editing commands.</p>
<h2>USE OF '\t' IN SED SCRIPTS:</h2>
<p>For clarity in documentation, we have  used<br />
the expression '\t' to indicate a tab character (0x09) in the  scripts.<br />
However, most versions of sed do not recognize the '\t'  abbreviation,<br />
so when typing these scripts from the command line, you should press<br />
the TAB key instead. '\t' is supported as a regular expression<br />
metacharacter in awk, perl, and in a few implementations of sed.</p>
<h2>VERSIONS OF SED:</h2>
<p>Versions of sed do differ, and some slight  syntax<br />
variation is to be expected. In particular, most do not support the<br />
use of labels (:name) or branch instructions (b,t) within editing<br />
commands, except at the end of those commands. We have used the  syntax<br />
which will be portable to most users of sed, even though the popular<br />
GNU versions of sed allow a more succinct syntax. When the reader  sees<br />
a fairly long command such as this:</p>
<pre>sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d</pre>
<p>it is heartening to know that GNU sed will let you reduce it to:</p>
<pre>sed '/AAA/b;/BBB/b;/CCC/b;d'</pre>
<p>In addition, remember that while many versions of sed accept a  command<br />
like "/one/ s/RE1/RE2/", some do NOT allow "/one/! s/RE1/RE2/",  which<br />
contains space before the 's'. Omit the space when typing the  command.</p>
<h2>OPTIMIZING FOR SPEED:</h2>
<p>If execution speed needs to be increased  (due to<br />
large input files or slow processors or hard disks), substitution  will<br />
be executed more quickly if the "find" expression is specified  before<br />
giving the "s/.../.../" instruction. Thus:</p>
<pre>sed 's/foo/bar/g' filename # standard replace command
sed '/foo/ s/foo/bar/g' filename # executes more quickly
sed '/foo/ s//bar/g' filename # shorthand sed syntax</pre>
<p>On line selection or deletion in which you only need to output  lines<br />
from the first part of the file, a "quit" command (q) in the script<br />
will drastically reduce processing time for large files. Thus:</p>
<pre>sed -n '45,50p' filename # print line nos. 45-50 of a file
sed -n '51q;45,50p' filename # same, but executes much faster</pre>
<p>If you have any additional scripts to contribute or if you find  errors<br />
in this document, please send e-mail to the compiler. Indicate the<br />
version of sed you used, the operating system it was compiled for, and<br />
the nature of the problem. Various scripts in this file were written<br />
or contributed by:</p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=28</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated wordpress and things</title>
		<link>http://anatexis.net/wordpress/?p=27&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updated-wordpress-and-things</link>
		<comments>http://anatexis.net/wordpress/?p=27#comments</comments>
		<pubDate>Mon, 21 Dec 2009 18:02:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=27</guid>
		<description><![CDATA[Seems to be working fine so far, but if you notice anything funky then please let me know!]]></description>
			<content:encoded><![CDATA[<p>Seems to be working fine so far, but if you notice anything funky then please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=27</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Open Instrumentation on Ubuntu 64bit</title>
		<link>http://anatexis.net/wordpress/?p=22&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-open-instrumentation-on-ubuntu-64bit</link>
		<comments>http://anatexis.net/wordpress/?p=22#comments</comments>
		<pubDate>Fri, 04 Dec 2009 02:08:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=22</guid>
		<description><![CDATA[I have a Syscomp Circuit Gear Oscilloscope, its a nice little USB device&#8230;. but they dont supply drivers that work under 64bit Linux, however, i did find that someone had done the work to make them work under 64bit Suse, and saved it as a RPM file. getting this into Ubuntu proved to be an [...]]]></description>
			<content:encoded><![CDATA[<p>I have a Syscomp Circuit Gear  Oscilloscope, its a nice little USB device&#8230;. but they dont supply drivers that work under 64bit Linux,</p>
<p>however, i did find that someone had done the work to make them work under 64bit Suse, and saved it as a RPM file.</p>
<p>getting this into Ubuntu proved to be an issue&#8230;.</p>
<p><span id="more-22"></span></p>
<p>first i downloaded the amd64 file from here http://software.opensuse.org/search?q=syscomp-cgr</p>
<p>then i installed alien, use this to convert package format&#8217;s</p>
<pre>&gt;sudo apt-get install alien</pre>
<p>if one then tries to convert the rpm you get this</p>
<pre>&gt;sudo alien syscomp-cgr-1.12-5.1.x86_64.rpm
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
error: incorrect format: unknown tag
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
warning: syscomp-cgr-1.12-5.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 27805e33
Unpacking of 'syscomp-cgr-1.12-5.1.x86_64.rpm' failed at /usr/share/perl5/Alien/Package/Rpm.pm line 155.</pre>
<p>This is a result of this bug in the ubuntu package&#8230;. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=509444</p>
<p>using the suggested work around you get &#8230;</p>
<pre>&gt;cat syscomp-cgr-1.12-5.1.x86_64.rpm  | rpm2cpio | lzma -d | cpio -ivd</pre>
<p>which produces a series of files under a usr, directory.  copying these all to the right places&#8230;</p>
<pre>&gt;sudo cp ./usr/bin/* /usr/bin/
&gt;sudo cp ./usr/lib/syscomp /usr/lib/
&gt;sudo cp ./usr/share/doc/syscomp /usr/share/doc/syscomp/</pre>
<p>Meant that i could run the program&#8230;</p>
<pre>&gt;syscomp-cgr
Error in startup script: can't find package Img
 while executing
"package require Img"
 (file "/usr/lib/syscomp/CGR101-1.12/main.tcl" line 51)</pre>
<p>so I then installed the tcl/tk package Img</p>
<pre>&gt; sudo apt-get install libtk-img-dev</pre>
<p>which seems to make everything work! just run syscomp-cgr and the program loads right up and found the Oscilloscope without a problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=22</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ploticus scripts&#8230;</title>
		<link>http://anatexis.net/wordpress/?p=20&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ploticus-scripts</link>
		<comments>http://anatexis.net/wordpress/?p=20#comments</comments>
		<pubDate>Tue, 27 Oct 2009 16:33:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[charting]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ploticus]]></category>

		<guid isPermaLink="false">http://anatexis.net/wordpress/?p=20</guid>
		<description><![CDATA[I have found it very usefull to use ploticus to create simple plots via scripts this script plots a time lines, for things like volcanic eruptions. svn link the ploticus script looks like this svn link]]></description>
			<content:encoded><![CDATA[<p>I have found it very usefull to use ploticus to create simple plots via scripts this script plots a time lines, for things like volcanic eruptions.</p>
<p><a title="svn link" href="http://anatexis.net/websvn/listing.php?repname=Presentations&#038;path=%2FOkmok-Kasatochi+Seminar%2FSource_Images%2Fscripts%2FEruption-timelines%2F#_Okmok-Kasatochi%20Seminar_Source_Images_scripts_Eruption-timelines_" target="_blank">svn link</a></p>
<p>the ploticus script looks like this</p>
<p><a title="link to ploticus script" href="http://anatexis.net/websvn/filedetails.php?repname=Presentations&#038;path=%2FOkmok-Kasatochi+Seminar%2FSource_Images%2Fscripts%2FEruption-timelines%2FOkmok2.pl" target="_blank">svn link</a></p>
]]></content:encoded>
			<wfw:commentRss>http://anatexis.net/wordpress/?feed=rss2&#038;p=20</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

