2

I used split -b 32m "file.bz2" "file.bz2.part-" to split a file and it created more than 50 parts. From googling, the way I found to reassemble the parts is to cat file.bz2.part-aa file.bz2.part-ab > file.bz2, while enumerating all the 50+ parts. Is there an easier way to reassemble the parts wherein I no longer need to list all those parts explicitly?

I'm using Fedora 12.

7

This is what wildcards and brace expansion are for. See if echo file.bz2.part-* returns the filenames in the desired order, and use cat file.bz2.part-* > file.bz2 if it does. Otherwise, figure out some other more complex expansion that does.

| improve this answer | |
4

split creates its partial file names in ascending lexicographical order. Since wildcard expansions lists the files in lexicographical order, cat file.bz2part-* > file.bz2 will concatenate the parts in the right order.

| improve this answer | |
0

Try:

for i in `ls file.part-* |sort`; do echo $i; cat $i >> newfile; done
| improve this answer | |
  • the back ticks were stripped off. add a back tick in front of ls and to the right of sort. – stuart Oct 22 '10 at 1:51
  • 1
    Fixed, the back ticks are added back as they were intended. – Gaff Jul 2 '11 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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