<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments for Anton Olsen . com</title>
	<atom:link href="http://antonolsen.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://antonolsen.com</link>
	<description></description>
	<pubDate>Mon, 08 Sep 2008 07:56:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>Comment on It Makes my Taco Pop! by Anton Olsen . com &#187; Blog Archive &#187; Bookmarks for September 6th</title>
		<link>http://antonolsen.com/2008/08/29/it-makes-my-taco-pop/#comment-3572</link>
		<dc:creator>Anton Olsen . com &#187; Blog Archive &#187; Bookmarks for September 6th</dc:creator>
		<pubDate>Sun, 07 Sep 2008 05:01:06 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/2008/08/29/it-makes-my-taco-pop/#comment-3572</guid>
		<description>[...] It Makes my Taco Pop! - For some reason this article is hot on google now. Getting a lot of links from search. [...]</description>
		<content:encoded><![CDATA[<p>[...] It Makes my Taco Pop! - For some reason this article is hot on google now. Getting a lot of links from search. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on BASH: Split a string without &#039;cut&#039; or &#039;awk&#039; by Jim Hertzler</title>
		<link>http://antonolsen.com/2006/04/10/bash-split-a-string-without-cut-or-awk/#comment-3566</link>
		<dc:creator>Jim Hertzler</dc:creator>
		<pubDate>Fri, 05 Sep 2008 22:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=116#comment-3566</guid>
		<description>Go to:

http://www.linuxquestions.org/questions/programming-9/bash-shell-script-split-array-383848/?posted=1#post3270996

And see:

IP=1.2.3.4; IP=(${IP//./ }); Rev=${IP[3]}.${IP[2]}.${IP[1]}.${IP[0]}</description>
		<content:encoded><![CDATA[<p>Go to:</p>
<p><a href="http://www.linuxquestions.org/questions/programming-9/bash-shell-script-split-array-383848/?posted=1#post3270996" rel="nofollow">http://www.linuxquestions.org/questions/programming-9/bash-shell-script-split-array-383848/?posted=1#post3270996</a></p>
<p>And see:</p>
<p>IP=1.2.3.4; IP=(${IP//./ }); Rev=${IP[3]}.${IP[2]}.${IP[1]}.${IP[0]}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on BASH: Split a string without &#039;cut&#039; or &#039;awk&#039; by Anton</title>
		<link>http://antonolsen.com/2006/04/10/bash-split-a-string-without-cut-or-awk/#comment-3565</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Fri, 05 Sep 2008 15:46:49 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=116#comment-3565</guid>
		<description>Jim,

Thanks!  I hadn't known about the IFS internal variable.</description>
		<content:encoded><![CDATA[<p>Jim,</p>
<p>Thanks!  I hadn&#039;t known about the IFS internal variable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on BASH: Split a string without &#039;cut&#039; or &#039;awk&#039; by Jim Hertzler</title>
		<link>http://antonolsen.com/2006/04/10/bash-split-a-string-without-cut-or-awk/#comment-3564</link>
		<dc:creator>Jim Hertzler</dc:creator>
		<pubDate>Fri, 05 Sep 2008 15:39:40 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=116#comment-3564</guid>
		<description>#!/bin/bash
# Split the command line argument on the colon character.

IFS=":"; declare -a Array=($*)

echo "Array[0]=${Array[0]}"
echo "Array[1]=${Array[1]}"
echo "Array[2]=${Array[2]}"
echo "Array[3]=${Array[3]}"</description>
		<content:encoded><![CDATA[<p>#!/bin/bash<br />
# Split the command line argument on the colon character.</p>
<p>IFS=&#034;:&#034;; declare -a Array=($*)</p>
<p>echo &#034;Array[0]=${Array[0]}&#034;<br />
echo &#034;Array[1]=${Array[1]}&#034;<br />
echo &#034;Array[2]=${Array[2]}&#034;<br />
echo &#034;Array[3]=${Array[3]}&#034;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on read a file with bash by Anton</title>
		<link>http://antonolsen.com/2005/03/23/read-a-file-with-bash/#comment-3551</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Tue, 02 Sep 2008 14:31:04 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=24#comment-3551</guid>
		<description>In all cases above you can remove the else clause, it isn't doing anything for you.  Put 'fred=""' at the top of the loop, and just append to it in each "if".

You can use variable variables inside the loop so you don't have to repeat each if block.

To see how they work, try this:
VAR1=abc
abc=123
echo ${!VAR1}

Inside your while read loop you could do something like this:

fred=""
for VAR in col1 col2 col3 col4; do
   if [ -n "${!VAR} ] ; then
      fred=$fred"${!VAR}"
   fi
done</description>
		<content:encoded><![CDATA[<p>In all cases above you can remove the else clause, it isn&#039;t doing anything for you.  Put &#039;fred=&#034;"&#039; at the top of the loop, and just append to it in each &#034;if&#034;.</p>
<p>You can use variable variables inside the loop so you don&#039;t have to repeat each if block.</p>
<p>To see how they work, try this:<br />
VAR1=abc<br />
abc=123<br />
echo ${!VAR1}</p>
<p>Inside your while read loop you could do something like this:</p>
<p>fred=&#034;"<br />
for VAR in col1 col2 col3 col4; do<br />
   if [ -n "${!VAR} ] ; then<br />
      fred=$fred&#034;${!VAR}&#034;<br />
   fi<br />
done</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on read a file with bash by Francois</title>
		<link>http://antonolsen.com/2005/03/23/read-a-file-with-bash/#comment-3550</link>
		<dc:creator>Francois</dc:creator>
		<pubDate>Tue, 02 Sep 2008 10:20:09 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=24#comment-3550</guid>
		<description>Anton,

I have the following code to read in a file an process accordingly :

#/tmp/test.txt looks like this :
# 0-1&#124;0-2&#124;0-3&#124;0-4
# 1-1&#124;&#124;1-3&#124;1-4
# &#124;2-2&#124;2-3&#124;2-4
# 3-1&#124;3-2&#124;&#124;3-4

FILENAME=$1; #input filename
OIFS=$IFS;
IFS='&#124;';

while read col1 col2 col3 col4
  do
    if [ -n "$col1" ]; then
      fred="col1 = '$col1', ";
    else 
      fred="";
    fi
    if [ -n "$col2" ]; then
      fred=$fred"col2 = '$col2', ";
    else 
      fred=$fred;
    fi
    if [ -n "$col3" ]; then
      fred=$fred"col3 = '$col3', ";
    else
      fred=$fred;
    fi
    if [ -n "$col4" ]; then
      fred=$fred"col4 = '$col4'";
    else
      fred=$fred;
    fi
    echo $fred;
done &#60;$FILENAME

#the output looks like this
col1 = '0-1', col2 = '0-2', col3 = '0-3', col4 = '0-4'
col1 = '1-1', col3 = '1-3', col4 = '1-4'
col2 = '2-2', col3 = '2-3', col4 = '2-4'
col1 = '3-1', col2 = '3-2', col4 = '3-4'

I want to know - can I substitute 'col1 - col4' for a variable, since there is about 40 fields per line on the "real" file and to do more or less the same validation repetitively seems pointless.

any suggestions would be appreciated.

thanks</description>
		<content:encoded><![CDATA[<p>Anton,</p>
<p>I have the following code to read in a file an process accordingly :</p>
<p>#/tmp/test.txt looks like this :<br />
# 0-1|0-2|0-3|0-4<br />
# 1-1||1-3|1-4<br />
# |2-2|2-3|2-4<br />
# 3-1|3-2||3-4</p>
<p>FILENAME=$1; #input filename<br />
OIFS=$IFS;<br />
IFS=&#039;|';</p>
<p>while read col1 col2 col3 col4<br />
  do<br />
    if [ -n "$col1" ]; then<br />
      fred=&#034;col1 = &#039;$col1&#039;, &#034;;<br />
    else<br />
      fred=&#034;";<br />
    fi<br />
    if [ -n "$col2" ]; then<br />
      fred=$fred&#034;col2 = &#039;$col2&#039;, &#034;;<br />
    else<br />
      fred=$fred;<br />
    fi<br />
    if [ -n "$col3" ]; then<br />
      fred=$fred&#034;col3 = &#039;$col3&#039;, &#034;;<br />
    else<br />
      fred=$fred;<br />
    fi<br />
    if [ -n "$col4" ]; then<br />
      fred=$fred&#034;col4 = &#039;$col4&#039;&#034;;<br />
    else<br />
      fred=$fred;<br />
    fi<br />
    echo $fred;<br />
done &lt;$FILENAME</p>
<p>#the output looks like this<br />
col1 = &#039;0-1&#039;, col2 = &#039;0-2&#039;, col3 = &#039;0-3&#039;, col4 = &#039;0-4&#039;<br />
col1 = &#039;1-1&#039;, col3 = &#039;1-3&#039;, col4 = &#039;1-4&#039;<br />
col2 = &#039;2-2&#039;, col3 = &#039;2-3&#039;, col4 = &#039;2-4&#039;<br />
col1 = &#039;3-1&#039;, col2 = &#039;3-2&#039;, col4 = &#039;3-4&#039;</p>
<p>I want to know - can I substitute &#039;col1 - col4&#039; for a variable, since there is about 40 fields per line on the &#034;real&#034; file and to do more or less the same validation repetitively seems pointless.</p>
<p>any suggestions would be appreciated.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on What Do You Do? by Anton</title>
		<link>http://antonolsen.com/2008/08/29/what-do-you-do/#comment-3546</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Mon, 01 Sep 2008 16:10:46 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=830#comment-3546</guid>
		<description>I've used the Linux escape clause too, and it works reasonably well until they convert.  My parents are now running Linux so I actually can (and do) help out from time to time.  Fortunately Dad is adept enough to google the answer most of the time.

I'm sticking with "I build robots" though, it's definitely the more fun answer and usually results in better conversation.</description>
		<content:encoded><![CDATA[<p>I&#039;ve used the Linux escape clause too, and it works reasonably well until they convert.  My parents are now running Linux so I actually can (and do) help out from time to time.  Fortunately Dad is adept enough to google the answer most of the time.</p>
<p>I&#039;m sticking with &#034;I build robots&#034; though, it&#039;s definitely the more fun answer and usually results in better conversation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Robot Lawn Mower. by Anton</title>
		<link>http://antonolsen.com/2008/05/08/robot-lawn-mower/#comment-3545</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Mon, 01 Sep 2008 16:04:07 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=616#comment-3545</guid>
		<description>Thanks for the link, the pink wheels are awesome!  I'll post the Youtube up soon.</description>
		<content:encoded><![CDATA[<p>Thanks for the link, the pink wheels are awesome!  I&#039;ll post the Youtube up soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on BASH: Split a string without &#039;cut&#039; or &#039;awk&#039; by eureka tips</title>
		<link>http://antonolsen.com/2006/04/10/bash-split-a-string-without-cut-or-awk/#comment-3544</link>
		<dc:creator>eureka tips</dc:creator>
		<pubDate>Mon, 01 Sep 2008 08:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=116#comment-3544</guid>
		<description>This cool tip was a lot helpful one.....I did a srch for my problem of interpreting a .CSV and this works like a charm</description>
		<content:encoded><![CDATA[<p>This cool tip was a lot helpful one&#8230;..I did a srch for my problem of interpreting a .CSV and this works like a charm</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Robot Lawn Mower. by Tim Mooney</title>
		<link>http://antonolsen.com/2008/05/08/robot-lawn-mower/#comment-3538</link>
		<dc:creator>Tim Mooney</dc:creator>
		<pubDate>Sun, 31 Aug 2008 23:47:24 +0000</pubDate>
		<guid isPermaLink="false">http://antonolsen.com/?p=616#comment-3538</guid>
		<description>It's crazy that commercial robot lawn mowers cost so much.  I can understand that manual lawn mowers must cost hundreds of dollars; they have to do a perfect job on a lawn-mower-sized area of grass in about a third of a second.  They have to be powerful to do this, and they need updraft.

But robot lawn mowers can mosey around the yard all week.  They needn't be powerful, and so they also needn't be very robustly built.  They needn't start on the first pull; they don't need a big honking blade; they don't need to be made out of metal.  Made in a large quantity, a serviceable, low-end robot mower should cost around $100 (not including the battery, which should cost another $50, and not including the perimeter wire, which should cost around $30).

I think the reason available robot mowers cost a bundle is that there are lots of manual mowers out there that cost $400, making a $1000 price tag for a robot mower (certainly preferable to a manual mower) seem less ridiculous.

I got so peved about this that I made my own robot lawn mower from a child's ride-on toy (a Power Wheels Barbie Jeep).  If you wanna see it, there's a video on youtube: http://www.youtube.com/watch?v=zuXqg4q3cQ8</description>
		<content:encoded><![CDATA[<p>It&#039;s crazy that commercial robot lawn mowers cost so much.  I can understand that manual lawn mowers must cost hundreds of dollars; they have to do a perfect job on a lawn-mower-sized area of grass in about a third of a second.  They have to be powerful to do this, and they need updraft.</p>
<p>But robot lawn mowers can mosey around the yard all week.  They needn&#039;t be powerful, and so they also needn&#039;t be very robustly built.  They needn&#039;t start on the first pull; they don&#039;t need a big honking blade; they don&#039;t need to be made out of metal.  Made in a large quantity, a serviceable, low-end robot mower should cost around $100 (not including the battery, which should cost another $50, and not including the perimeter wire, which should cost around $30).</p>
<p>I think the reason available robot mowers cost a bundle is that there are lots of manual mowers out there that cost $400, making a $1000 price tag for a robot mower (certainly preferable to a manual mower) seem less ridiculous.</p>
<p>I got so peved about this that I made my own robot lawn mower from a child&#039;s ride-on toy (a Power Wheels Barbie Jeep).  If you wanna see it, there&#039;s a video on youtube: <a href="http://www.youtube.com/watch?v=zuXqg4q3cQ8" rel="nofollow">http://www.youtube.com/watch?v=zuXqg4q3cQ8</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
