Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've split a large file with the split command from a terminal and copied it from a usb-stick to my macbook.

This results in couple of files named 'xaa', 'xab', 'xac'.

How do I merge them together again from within a terminal?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted
cat xaa > newfile
cat xab >> newfile
cat xac >> newfile

Basically using a single '>' operand send the output to a new file. using a double '>>' operand makes it append the contents to the end of an existing file (and also out of interest create it if it does not already exist.

If all your files are definitely in a neat alphabetical order, then you could use:

cat x* > newfile

or

cat xaa xab xac > newfile

in case the filenames aren't in alphabetical order.

share|improve this answer
1  
You can also do cat xaa xab xac > newfile –  binarybob Mar 13 '12 at 19:57
    
but of course, this sounds logical! :-) thanks! –  Sander Versluys Mar 13 '12 at 20:01
    
It is the mac way after all. –  bmike Mar 13 '12 at 23:20
3  
@bmike More like the Unix way, am I right?! :) –  Mathias Bynens Mar 26 '12 at 6:56
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.