I'm with Brian on this one. I don't know of a way to truncate a file without playing with the filesystem.

- Sebastian


On Wed, 28 Jun 2006, Brian Chrisman wrote:

I kind of doubt that there's anything else you can do. I think you'd have to have some program that manipulates the the filesystem inodes to do what you want. Generally you are limited to the system call interface like 'open', 'read', 'write', 'truncate'.. and all that stuff. You could certainly write null characters over the first 300 lines, but if that doesn't do what you want, I'm not certain what else will, barring some sort of hacky work with a filesystem debugger tool.

You could also have some part of your program which maintains a current offset into the file, and automatically does a 'seek' to that position when you next run it... it'd be a dirty hack, but it might be what you want. Then you'd have to write your code in some full programming language, not sed.

-Brian


Grant Kelly wrote:
Alright unix fans, who can answer this the best?

I have a text file, it's about 2.3 GB. I need to delete the first 300
lines, and I don't want to have to load the entire thing into an
editor.

I'm trying `sed '1,300d' inputfile > output file`  but it's taking a
long time (and space) to output everything to the new file.

There has got to be a better way, a way that can do this in-place...


Grant

_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug


_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug


_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug

Reply via email to