From: ralf Date: 2006-02-07T22:08:21+09:00 Subject: Grep via Ruby Hi, I'd like to have a "grep" with case-insensitive match. normal grep does not have this functionality (afaik), but ruby does. So this is, what i wrote: cat rgrep: #!/usr/bin/env ruby # Grep with full regexp-functionality via ruby if ARGV.shift == "-p" pattern = Regexp.new(ARGV.shift) else puts "Please give me a pattern with the '-p' option" exit end ARGV.each do |filename| File.open(filename) do |file| file.each do |line| puts "#{filename} #{file.lineno.to_s}: #{line}" if pattern.match(line) end end end Using it via: rgrep -p '/delete /i' *.php does not match anything, but this #!/usr/bin/env ruby # Grep with full regexp-functionality via ruby if ARGV.shift == "-p" pattern = Regexp.new(ARGV.shift) else puts "Please give me a pattern with the '-p' option" exit end ARGV.each do |filename| File.open(filename) do |file| file.each do |line| puts "#{filename} #{file.lineno.to_s}: #{line}" if /delete /i.match(line) end end end DOES match. Does anyone see the bug? Maybe this can be done a lot easier by using ARGF?? Thanks in advance Ralf M�ller