4 ms·
dunno about windows, but in llinux its fairly simple. I've had to do do this a lot of this sort of thing on big disk images my friend made with some weird progr
by davidork 7y ago
dunno about windows, but in llinux its fairly simple. I've had to do do this a lot of this sort of thing on big disk images my friend made with some weird program that pads the start of everything with 512 bytes of some random crap.
dd skip=10 iflag=skip_bytes if=original.file of=first10ktrimmed.file
despite being old, and the amount of insanely horrible things you can do when you mess up the syntax or mistype something using it, dd is fucking amazing.
to be fair, its not directly editing the file, but making a copy with the first 10k skipped.
you could have a jump/pointer that points to the shortened first block of the file and then at the end of that, a pointer/jump to pick up where the rest of the file continues, but you'd wind up with misalignment and fs fragmentation.
- CrowFly 7y agoLinux doesn't implement sparse files.
- fl0wenol 7y agoYes it does? The details are file system specific and if they support mmap then it's also likely there's a page alignment requirement but that's not atypical.
- LeoPanthera 7y agoNot only does it do so, but dd directly supports sparse files, using the "sparse" conv symbol.
- cortesoft 7y agoThis really isn't solving the problem posed by the author, though. Copying the file is a completely different thing; for one, it will require double the space and take a lot longer. What if you need to chop the first 10 bytes from a file that is more than half your disk?
- eps 7y ago_Copying_ what you want from a file is trivial on any OS. The question is to how to trim the file head _in place_.
- chrisseaton 7y ago> to be fair, its not directly editing the file, but making a copy with the first 10k skipped ...so missing the point of the question entirely.