Log in

No account? Create an account
Previous Entry Share Next Entry
How to split & join large files, binary, text etc.
In Linux, we can split large files with split command. And to join you just need to cat the files into one file.

Split can be used on binaries, text files whatever.

To split ->

# split --byte=10k /path/to/large/file /path/to/output/files/prefix

For eg. I want to split /root/slapd binary file.

Size of it is 1.3M

root@neel:~/test# ls -lh /root/slapd
-rwxr-xr-x 1 root root 1.3M 2011-05-11 13:49 /root/slapd

I want to split it into 10kb files. Just give below commands.

root@neel:~# split --byte=10k /root/slapd /root/test/prefix

It will split slapd into 10kb files under /root/test directory and all filenames will be prefixaa, prefixab etc…

To retrieve original file you need to do cat into different filenames.

root@neel:~# cat /root/test/prefix* > /root/neel

It created a binary file under /root with name neel.

Then I checked md5sum value of both files to check integrity:

root@neel:~/test# md5sum /root/neel
f1ac87370fea4cc9922acc443c19d518 /root/neel

root@neel:~/test# md5sum /root/slapd
f1ac87370fea4cc9922acc443c19d518 /root/slapd

If you notice both values are same.