Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a better way to join files that have been splitted than just doing a "cat" or "join"? These commands just copy the file streams into a new file on disk. A much better way would be manipulating the filesystem pointers to join the files into one big continuous file. Of course this would be filesystem specific. Is there something available for ext2 or ext3?

share|improve this question

3 Answers 3

No, the correct way to split files is:

split bigfile

and conCATenate them:

cat x* > newbigfile

Trying to do this with the underlying filesystem is the wrong approach if for no other reason than it wouldn't be portable.

share|improve this answer
    
There are several use cases where portability is not the primary issue. Partition tools work with these kinds of issues all the time. I can't see why this shouldn't be available - at least for a root user. –  Eddy Yosso Jul 12 '10 at 9:51
    
See part of Gary's answer. Filesystem abstraction would be broken. You're catting files, not manipulating filesystems. That's the difference between split/cat and parted. The rest of the OS wouldn't have any idea why all of a sudden something weird happened to some otherwise perfectly normal files. I wouldn't run such a utility except on an unmounted filesystem. –  Dennis Williamson Jul 12 '10 at 11:59

Yes. And it makes no sense for this kind of special case to be in userspace. It would break the whole idea of the filesystem abstraction.

share|improve this answer
1  
Are you saying "yes" to the OP's question 'Is there a better way to join files that have been splitted than just doing a "cat" or "join"?'? The rest of your answer seems to say "no". –  Dennis Williamson Jul 11 '10 at 22:14
    
Actually, what I'm saying is it can be done in kernelspace, since anything can be done in kernelspace. –  gtrak Mar 21 '11 at 1:37

Once I had one file with 2Gb and I wanted to add a file at the header of that.

I would cat a new file, but was concerned about performance.

So I ended up using "vi" on the big file and typed :read header.txt at the beginning of the file, then save it.

It worked, and faster than cat.

Maybe "vi" is clever at rewriting the file, I've never seen the code, though.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.