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

John Wells jb at devsea.com
Tue Jan 20 00:36:28 EST 2004


Fletch,

heh...yes, I think you do have a bit too much time on your hands ;-)...
Was hoping there was some shell syntatic sugar or cmdline tool, but I
suppose perl is always there to fill that gap.  Thanks!

John


Fletch said:
>
> 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
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>



More information about the Ale mailing list