On Fri, Aug 24, 2012 at 10:22 AM, Aravind K. <[email protected]> wrote:
> Hi All,
>
> I am working a ruby code to append lines to a existing file at some
> specified  location. I do that by finding a particular string and append
> the line below that. In a certain case i am trying to add a particular
> line say welcome before a existing line,
>
> Eg. line1
> line 2
> line3
> )
>
> line4
>
> I will need to add the line above line 4 as i cant append it after ) as
> there may be several )'s. What is the way that i can do this?
>
> It would be of great help. Thanks in advance.

Just iterate the file line by line and output the new line before you
output the matching line.

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to