|
How to Split and Merger long files? |
|
|
How to Split and Merger long files? Jesus asks: I have a question about the split Command… How can I “come back” to “largefile” from 126 small files?It sounds like the split command was used? If so, then you can use a for loop with file concatenation. First, I will split the files for my example:
$ ls -l big.log -rw-rw-r-- 1 brock brock 175743061 Oct 11 22:08 big.log $ expr 175743061 \/ 126 1394786 $ split -b 1394786 big.log $ ls -1 x* xaa xab ... xew Split creates its output files in decreasing alphabetic order. Thus when you list them in the shell they are in the order in which they were split. As such, you can simply use cat to merge the files. (Thanks to Paul and Davidov for pointing out my for loop was superfluous.) $ cat x* >merged.big.log $ ls -l *.log -rw-rw-r-- 1 brock brock 175743061 Oct 12 22:08 big.log -rw-rw-r-- 1 brock brock 175743061 Oct 12 01:11 merged.big.log $ diff merged.big.log big.log $ md5sum *.log 47de08911534957c1768968743468307 big.log 47de08911534957c1768968743468307 merged.big.log
|