[ale] dreaded spaces in file names....

Fletch fletch at phydeaux.org
Mon Jan 19 22:51:39 EST 2004


Or even this . . . 

(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



More information about the Ale mailing list