[Tfug] joining two large files on disk...

JD Rogers rogersjd at gmail.com
Mon Jun 14 14:13:22 MST 2010


> Without rewriting the data on disk? How would you possibly store the
> concatenated file, then? You could do `cat file1 file2 > newfile`, but I
> have a feeling that this isn't what you're thinking of.
>
> I'm gonna go out on a limb here and throw out an absolute, but I don't think
> there's any way to concatenate two (or more) files and store the result
> without writing *something* out to disk. For giggles, you can concatenate
> them to stdout all you want, though... ;-)

Heh, right. :-) I think I wasn't being clear.. when you have a huge
3GB file on your usb drive, and you copy it using 'cp file1 file2', it
will take some minutes to read and then write the data to a second set
bits on the disk. On the other hand, if you "mv file1 file2", the bits
don't get read and rewritten, the filename is just updated. It takes
almost no time.

So what I was wanting is to merge the two files so that the filesystem
knows that the bits stored at locations x:x+file1size and the bits
stored at y:y+file2size are all part of one contiguous file with a
single filename, albeit a fragmented file on the filesystem.




More information about the tfug mailing list