in reply to Re^2: Deleting all the data after a specific position in a text file.
in thread Deleting all the data after a specific position in a text file.

The problem is that we have to calculate the file size and then subtract to get the value of the truncate LENGTH.

Is that soo difficult?

Maybe you're making the same mistake as the other posters and thinking you need to open the file first and seek around in it? You don't:

c:\test>dir junk.dat 18/11/2011 19:23 893 junk.dat c:\test>perl -E"$f=pop; $s=-s($f); truncate $f, $s-40 or die $!" junk. +dat c:\test>dir junk.dat 18/11/2011 19:24 853 junk.dat

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^3: Deleting all the data after a specific position in a text file.
  • Download Code