[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



(yes, I got bored and I'm re-learning ruby)

#!/usr/bin/ruby

unless ARGV.size == 1
  $stderr.puts "usage: #{$0} pattern"
  exit 1
end

pattern = %r(#{ARGV[0]});

IO.popen( "locate .txt" ) do |locate|
  locate.readlines.grep(/\.txt$/).map { |n| n.chomp! }.each do |fname|
    begin
      File.open( fname, "r" ) do |cur|
        cur.each { |l| puts "#{fname}: #{l}" if l =~ pattern }
      end
    rescue IOError
      puts "problem opening #{fname}: #{$!}"
      next
    end 
  end
end

__END__

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00789" href="msg00789.html">[ale] dreaded spaces in file names....</a></strong>
<ul><li><em>From:</em> jb at devsea.com (John Wells)</li></ul></li>
<li><strong><a name="00794" href="msg00794.html">[ale] dreaded spaces in file names....</a></strong>
<ul><li><em>From:</em> dhurst at kennesaw.edu (Dow Hurst)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00778" href="msg00778.html">[ale] dreaded spaces in file names....</a></strong>
<ul><li><em>From:</em> jb at devsea.com (John Wells)</li></ul></li>
<li><strong><a name="00780" href="msg00780.html">[ale] dreaded spaces in file names....</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00785.html">[ale] &quot;Ghosting&quot; a Windows Machine Using Linux CD</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00782.html">[ale] &quot;Ghosting&quot; a Windows Machine Using Linux CD</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00780.html">[ale] dreaded spaces in file names....</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00789.html">[ale] dreaded spaces in file names....</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00781"><strong>Date</strong></a></li>
<li><a href="threads.html#00781"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>