From: Eric Russell Date: 2009-12-18T22:47:42+09:00 Subject: Re: grep a block try: #!/usr/bin/ruby filename = ARGV[0] File.open(filename).each do |line| if line =~ //..line =~ /<\/mms:MmsCcppAccept>/ puts line end end Is this what you're looking for?