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

Jeff Coy jcoy42 at gmail.com
Mon Jun 14 15:10:05 MST 2010


I know of nothing that would actually merge the data of 2 files into a
single file without rewriting.

While you probably could write something to chain the blocks from the 2nd
file onto the first, I don't think it would work.  I think there would be a
large gap created by anything that attempted to do a low level merge since
the first file probably ends with a block that is not full.

You could always

  cat file2 >> file1

and you would at least avoid the cost of rewriting file1.

And that would be fine.  Until the first typo where you accidentally do

  cat file2 > file1



On Mon, Jun 14, 2010 at 2:13 PM, JD Rogers <rogersjd at gmail.com> wrote:

> > 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.
>
> _______________________________________________
> Tucson Free Unix Group - tfug at tfug.org
> Subscription Options:
> http://www.tfug.org/mailman/listinfo/tfug_tfug.org
>



-- 
Morphic Resonance: the basis of memory in nature....the idea of mysterious
telepathy-type interconnections between organisms and of collective memories
within species.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tfug.org/pipermail/tfug_tfug.org/attachments/20100614/9de63329/attachment-0002.html>


More information about the tfug mailing list