Click to See Complete Forum and Search --> : how to remove a single line from a text file


jchibbra
05-21-2003, 04:36 PM
Hi guys,

my question is really simple.
How do I remove 1 line from a text file.

example:
I have a .htpasswd file with several entry.
I would like to remove the line which contain the login: bob

How do I do that when I don't want to put the file in an array, remove the entry from the array and then re write the file with the new array content.

Tks in advance

pyro
05-21-2003, 05:01 PM
I think you are going to have to do it that way. Reading from a file automatically puts the contents into an array, so it is logical that to remove a line, you loop through, remove the line, and re-write... Why can't you do it that way?

jchibbra
05-21-2003, 05:49 PM
I thought there was another way to do it more efficiently.
like open the file, read and cut the line and save the file.

Tks anyway