<?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>Module Lost &#187; shell</title>
	<atom:link href="http://www.modlost.net/home/tag/shell/feed" rel="self" type="application/rss+xml" />
	<link>http://www.modlost.net/home</link>
	<description>Thoughts about software development &#38; productivity</description>
	<lastBuildDate>Sat, 12 Jun 2010 03:05:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Finding file names without dots in their names</title>
		<link>http://www.modlost.net/home/article/finding-file-names-without-dots-in-their-names.html</link>
		<comments>http://www.modlost.net/home/article/finding-file-names-without-dots-in-their-names.html#comments</comments>
		<pubDate>Mon, 08 Oct 2007 20:09:36 +0000</pubDate>
		<dc:creator>Abner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Information Technologies]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.modlost.net/wordpress/?p=200</guid>
		<description><![CDATA[Yesterday, I received an interesting question in a company where I&#8217;m a consultant. They wanted to find all file names in the source code of &#8220;XYZ&#8221; application without dots in their names so they were looking for the easiest way to do this task in GNU/LiNUX. I&#8217;ve never needed to do that kind of search [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I received an interesting question in a company where I&#8217;m a consultant. They wanted to find all file names in the source code of &#8220;XYZ&#8221; application without dots in their names so they were looking for the easiest way to do this task in GNU/LiNUX.</p>
<p>I&#8217;ve never needed to do that kind of search so I&#8217;ve recommended to read find command man page and use regular expressions. At home, I&#8217;ve found an nice way to do this task:</p>
<pre><code><strong>modlost@optimus:~/tmp$ </strong>mkdir -p testdir/1/2/3
<strong>modlost@optimus:~/tmp$ </strong>touch testdir/1/withoutdots
<strong>modlost@optimus:~/tmp$ </strong>touch testdir/1/2/with.dot
<strong>modlost@optimus:~/tmp$ </strong>touch testdir/1/2/3/withoutdots
<strong>modlost@optimus:~/tmp$ </strong>find testdir -type f -regex '[^.]*'
testdir/1/2/3/withoutdots
testdir/1/withoutdots
</code></pre>




	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html&amp;title=Finding%20file%20names%20without%20dots%20in%20their%20names&amp;bodytext=Yesterday%2C%20I%20received%20an%20interesting%20question%20in%20a%20company%20where%20I%27m%20a%20consultant.%20They%20wanted%20to%20find%20all%20file%20names%20in%20the%20source%20code%20of%20%22XYZ%22%20application%20without%20dots%20in%20their%20names%20so%20they%20were%20looking%20for%20the%20easiest%20way%20to%20do%20this%20task%20in%20GNU%2F" title="Digg"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html&amp;title=Finding%20file%20names%20without%20dots%20in%20their%20names&amp;notes=Yesterday%2C%20I%20received%20an%20interesting%20question%20in%20a%20company%20where%20I%27m%20a%20consultant.%20They%20wanted%20to%20find%20all%20file%20names%20in%20the%20source%20code%20of%20%22XYZ%22%20application%20without%20dots%20in%20their%20names%20so%20they%20were%20looking%20for%20the%20easiest%20way%20to%20do%20this%20task%20in%20GNU%2F" title="del.icio.us"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html&amp;t=Finding%20file%20names%20without%20dots%20in%20their%20names" title="Facebook"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html&amp;title=Finding%20file%20names%20without%20dots%20in%20their%20names&amp;annotation=Yesterday%2C%20I%20received%20an%20interesting%20question%20in%20a%20company%20where%20I%27m%20a%20consultant.%20They%20wanted%20to%20find%20all%20file%20names%20in%20the%20source%20code%20of%20%22XYZ%22%20application%20without%20dots%20in%20their%20names%20so%20they%20were%20looking%20for%20the%20easiest%20way%20to%20do%20this%20task%20in%20GNU%2F" title="Google Bookmarks"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.friendfeed.com/share?title=Finding%20file%20names%20without%20dots%20in%20their%20names&amp;link=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html" title="FriendFeed"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html&amp;title=Finding%20file%20names%20without%20dots%20in%20their%20names&amp;source=Module+Lost+Thoughts+about+software+development+%26amp%3B+productivity&amp;summary=Yesterday%2C%20I%20received%20an%20interesting%20question%20in%20a%20company%20where%20I%27m%20a%20consultant.%20They%20wanted%20to%20find%20all%20file%20names%20in%20the%20source%20code%20of%20%22XYZ%22%20application%20without%20dots%20in%20their%20names%20so%20they%20were%20looking%20for%20the%20easiest%20way%20to%20do%20this%20task%20in%20GNU%2F" title="LinkedIn"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Finding%20file%20names%20without%20dots%20in%20their%20names%20-%20http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html" title="Twitter"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html&amp;t=Finding%20file%20names%20without%20dots%20in%20their%20names" title="MySpace"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a>
	<a rel="nofollow"  target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html&amp;title=Finding%20file%20names%20without%20dots%20in%20their%20names&amp;body=Yesterday%2C%20I%20received%20an%20interesting%20question%20in%20a%20company%20where%20I%27m%20a%20consultant.%20They%20wanted%20to%20find%20all%20file%20names%20in%20the%20source%20code%20of%20%22XYZ%22%20application%20without%20dots%20in%20their%20names%20so%20they%20were%20looking%20for%20the%20easiest%20way%20to%20do%20this%20task%20in%20GNU%2F" title="Ping.fm"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Finding%20file%20names%20without%20dots%20in%20their%20names&amp;url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Ffinding-file-names-without-dots-in-their-names.html" title="Slashdot"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.modlost.net/home/article/finding-file-names-without-dots-in-their-names.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash Shell Scripting &amp; Progress Indicators</title>
		<link>http://www.modlost.net/home/article/bash-shell-scripting-a-progress-indicators.html</link>
		<comments>http://www.modlost.net/home/article/bash-shell-scripting-a-progress-indicators.html#comments</comments>
		<pubDate>Thu, 23 Mar 2006 17:09:35 +0000</pubDate>
		<dc:creator>Abner</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Information Technologies]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.modlost.net/wordpress/?p=73</guid>
		<description><![CDATA[This week was the second preliminary laboratory of Operating Systems course in the PUCP. One topic I had to explain to the students was a little introduction to shell scripting. I told them about an application I made using only Bash Shell Scripting. Why did I use shell scripting? well, because that application had to take a [...]]]></description>
			<content:encoded><![CDATA[<p>This week was the second preliminary laboratory of Operating Systems course in the <a href="http://www.pucp.edu.pe" target="_blank">PUCP</a>. One topic I had to explain to the students was a little introduction to shell scripting.</p>
<p><span id="more-73"></span></p>
<p>I told them about an application I made using only Bash Shell Scripting. Why did I use shell scripting? well, because that application had to take a big amount of data (more than 4GB) from two differents databases (oracle &amp; mysql) and do a complex bussiness logic. The solution I provided was filtering the input data with some simple rules (using awk &amp; sed) and discarded unuseful data (aprox 40%). After that, the application used some temporary tables (to do the complex logic) on mysql and got the expected result. It was unncessary to make a compiled program.</p>
<p>BTW, we can do some interesting things with Shell Scripting. For example, a good practice is to give users a feedback that a script is not hung (progress indicator). This is specially useful with long time jobs.</p>
<p>I will show two kinds of progress indicators:</p>
<p class="contentheading">Simple Progress Indicator</p>
<p>Print a sequence of dots.</p>
<pre><code>#!/bin/bash
#
# Copyright © Abner Ballardo Urco
# http://www.modlost.net
#

#
# Simple Progress Indicator
#
function simple_progress_ind {
  # Sleep at least 1 second otherwise this algoritm will consume
  # a lot system resources.
  interval=1

  while true
  do
    echo -ne "."
    sleep $interval
  done
}

#
# Stop distraction
#
function stop_progress_ind {
  exec 2&gt;/dev/null
  kill $1
  echo -en "\n"
}

echo "Simple Progress Indicator"
echo -n "Processing "

simple_progress_ind &amp;
pid=$!

# Thanks Stephen Concannon for sending this fix.
# If the main script is interrupted, this line takes care
# of stopping the progress indicator
trap "stop_progress_ind $pid; exit" INT TERM EXIT

/long/time/job/zzZZzz.sh

stop_progress_ind $pid
</code></pre>
<p class="contentheading">Cool Progress Indicator</p>
<p>Print a rotating line.</p>
<pre><code>#!/bin/bash
#
# Copyright © Abner Ballardo Urco
# http://www.modlost.net
#

#
# Cool Progress Indicator
#
function cool_progress_ind {
  chars=( "-" "\\" "|" "/" )
  interval=1
  count=0

  while true
  do
    pos=$(($count % 4))

    echo -en "\b${chars[$pos]}"

    count=$(($count + 1))
    sleep $interval
  done
}

#
# Stop progress indicator
#
function stop_progress_ind {
  exec 2&gt;/dev/null
  kill $1
  echo -en "\n"
}

echo "Cool Progress Indicator"
echo -n "Processing "

cool_progress_ind &amp;
pid=$!

# Thanks Stephen Concannon for sending this fix.
# If the main script is interrupted, this line takes care
# of stopping the progress indicator
trap "stop_progress_ind $pid; exit" INT TERM EXIT

/long/time/job/zzZZZzz.sh

stop_progress_ind $pid
</code></pre>




	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html&amp;title=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators&amp;bodytext=This%20week%20was%20the%20second%20preliminary%20laboratory%20of%20Operating%20Systems%20course%20in%20the%C2%A0PUCP.%C2%A0One%20topic%20I%20had%20to%20explain%20to%20the%20students%20was%20a%20little%20introduction%20to%20shell%20scripting.%0D%0A%0D%0A%0D%0A%0D%0AI%20told%20them%20about%20an%20application%20I%20made%20using%20only%20Bash%20Shell%20S" title="Digg"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html&amp;title=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators&amp;notes=This%20week%20was%20the%20second%20preliminary%20laboratory%20of%20Operating%20Systems%20course%20in%20the%C2%A0PUCP.%C2%A0One%20topic%20I%20had%20to%20explain%20to%20the%20students%20was%20a%20little%20introduction%20to%20shell%20scripting.%0D%0A%0D%0A%0D%0A%0D%0AI%20told%20them%20about%20an%20application%20I%20made%20using%20only%20Bash%20Shell%20S" title="del.icio.us"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html&amp;t=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators" title="Facebook"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html&amp;title=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators&amp;annotation=This%20week%20was%20the%20second%20preliminary%20laboratory%20of%20Operating%20Systems%20course%20in%20the%C2%A0PUCP.%C2%A0One%20topic%20I%20had%20to%20explain%20to%20the%20students%20was%20a%20little%20introduction%20to%20shell%20scripting.%0D%0A%0D%0A%0D%0A%0D%0AI%20told%20them%20about%20an%20application%20I%20made%20using%20only%20Bash%20Shell%20S" title="Google Bookmarks"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.friendfeed.com/share?title=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators&amp;link=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html" title="FriendFeed"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html&amp;title=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators&amp;source=Module+Lost+Thoughts+about+software+development+%26amp%3B+productivity&amp;summary=This%20week%20was%20the%20second%20preliminary%20laboratory%20of%20Operating%20Systems%20course%20in%20the%C2%A0PUCP.%C2%A0One%20topic%20I%20had%20to%20explain%20to%20the%20students%20was%20a%20little%20introduction%20to%20shell%20scripting.%0D%0A%0D%0A%0D%0A%0D%0AI%20told%20them%20about%20an%20application%20I%20made%20using%20only%20Bash%20Shell%20S" title="LinkedIn"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators%20-%20http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html" title="Twitter"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html&amp;t=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators" title="MySpace"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" /></a>
	<a rel="nofollow"  target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html&amp;title=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators&amp;body=This%20week%20was%20the%20second%20preliminary%20laboratory%20of%20Operating%20Systems%20course%20in%20the%C2%A0PUCP.%C2%A0One%20topic%20I%20had%20to%20explain%20to%20the%20students%20was%20a%20little%20introduction%20to%20shell%20scripting.%0D%0A%0D%0A%0D%0A%0D%0AI%20told%20them%20about%20an%20application%20I%20made%20using%20only%20Bash%20Shell%20S" title="Ping.fm"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Bash%20Shell%20Scripting%20%26%20Progress%20Indicators&amp;url=http%3A%2F%2Fwww.modlost.net%2Fhome%2Farticle%2Fbash-shell-scripting-a-progress-indicators.html" title="Slashdot"><img src="http://www.modlost.net/home/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.modlost.net/home/article/bash-shell-scripting-a-progress-indicators.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
