For everything in this question pretend the system only has one disk and filesystem. (we are not writing to different partitions, disks or filesystems)
I am working on a project that
cats very large .MTS files into one huge .MTS file. This requires reading each small file and writing them to a new bigger file then deleting the small files. This takes a very long time with files this big.
My understanding -
cp takes longer than
cp reads the file and writes it to a different place on the disk.
mv on the other hand doesn't copy or move the file.
mv removes the reference to the file and creates a new one at the new location. For instance
mv /tmp/foo /tmp/bar leaves the file as is on disk and removes the reference that directs
/tmp/foo to the file on disk and adds the new reference that points
/tmp/bar to the file on disk.
cat is like
cp because it copies the file to the new location. With such large files and no need for the smaller files when I am done, is there something similar to
cat that uses
mv instead of
Theory (I may have it wrong)
It is already common for files to be stored scattered about the drive. For instance a 2GB file might have several smaller chunks stored in different parts of the drive. This way when a 5K files is deleted it can be overwritten with part of a 20MB file. If we left the 2GB files where they are and just reference all the parts it seems like we could make the same effect as
cat foo/* >> bar/bigfile.MTS; rm foo/* in a fraction of the time.
If there is nothing out there that does this and it is a bad idea, can anyone give me example of why? Is it bad to encourage mucking up the disk with scattered file chunks?