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

Dow Hurst dhurst at kennesaw.edu
Tue Jan 20 09:34:00 EST 2004


Thanks!  I needed to see that in ruby!
Dow


Fletch wrote:
> 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__
> 

-- 
__________________________________________________________
Dow Hurst                  Office: 770-499-3428            *
Systems Support Specialist    Fax: 770-423-6744            *
1000 Chastain Rd. Bldg. 12                                 *
Chemistry Department SC428  Email:   dhurst at kennesaw.edu   *
Kennesaw State University         Dow.Hurst at mindspring.com *
Kennesaw, GA 30144                                         *
************************************************************
This message (including any attachments) contains          *
confidential information intended for a specific individual*
and purpose, and is protected by law.  If you are not the  *
intended recipient, you should delete this message and are *
hereby notified that any disclosure, copying, distribution *
of this message, or the taking of any action based on it,  *
is strictly prohibited.                                    *
************************************************************



More information about the Ale mailing list