removing a line from a text file?

Posted by Blackbinary on Stack Overflow See other posts from Stack Overflow or by Blackbinary
Published on 2011-03-06T21:33:02Z Indexed on 2011/03/07 0:10 UTC
Read the original article Hit count: 243

Filed under:
|
|

Hi all.

I am working with a text file, which contains a list of processes under my programs control, along with relevant data.

At some point, one of the processes will finish, and thus will need to be removed from the file (as its no longer under control).

Here is a sample of the file contents (which has enteries added "randomly"):

PID=25729 IDLE=0.200000 BUSY=0.300000 USER=-10.000000
PID=26416 IDLE=0.100000 BUSY=0.800000 USER=-20.000000
PID=26522 IDLE=0.400000 BUSY=0.700000 USER=-30.000000

So for example, if I wanted to remove the line that says PID=26416.... how could I do that, without writing the file over again?

I can use external unix commands, however I am not very familiar with them so please if that is your suggestion, give an example.

Thanks!

© Stack Overflow or respective owner

Related posts about c

    Related posts about file