From: Lars Haugseth Date: 2012-09-06T00:32:36+09:00 Subject: Re: get a string from lines of output On 09/05/2012 04:49 PM, Ferdous ara wrote: > get Disk Name from bellow text > > hi, > as an example , I have bellow text in a file, please look at under > Logical Drive: 13 , i made Status = Failed > > So if its see Status=Failed, it will give the Disk name .( i was > thinking, if Status is failed then read next 4 lines , and get the > output from last line ) Have you tried implementing that? Did it work? If not, what happened? If you know that the disk name will always follow (ie. appear below) the status, try using a flip flop: File.foreach("status.txt") do |line| if line[/Status: Failed/] .. line[/Status: OK/] puts line if line[/Disk Name:/] end end -- Lars Haugseth