From: Thiago Lewin Date: 2011-03-10T21:25:32+09:00 Subject: Re: delete one line of file --20cf30434710eee45b049e1ff0eb Content-Type: text/plain; charset=ISO-8859-1 Hi Joyce, # First you should read the file: alunos = IO.readlines('alunos.txt') # return an array with all ids # Remove the selected id: alunos.delete_if do |linha| dados = linha.split(":") #"quebra" quando encontrar dois pontos outrosDados = dados[0].split("!") outrosDados == login end # Open the file and rewrite the content f = File.open('alunos.txt', 'w') alunos.each |a| f.puts a end f.close This should work! On Wed, Mar 9, 2011 at 11:55 PM, Joyce Lima wrote: > I'm doing one work school, sorry don't write english very good, I'm > brasilian. I want delete only one line of File. > I have two files and have to handle them according > with data received by users in case some have > Students enrolled in the following way name! id: registration. > The user enters the id of the student, I have to search > the file and delete the row for that id. Since there > I found nothing specific files I'm using > delete_if, look at the code, I'll attach it. > > Attachments: > http://www.ruby-forum.com/attachment/6016/bd.rb > > > -- > Posted via http://www.ruby-forum.com/. > > --20cf30434710eee45b049e1ff0eb--