As described in this hint, the split utility is a highly-useful tool for splitting a large file into pieces. Recently, however, I discovered that attempting to split a file into pieces 2GB in size or larger fails with an error:
$ split -b 2048m somelargefile
split: write: Invalid argument
This is caused by Apple shipping an older copy of split that uses signed long values for the byte count, limiting it to 2047MB. One workaround is to compile a new split utility that uses 64-bit integers, allowing a much larger byte count. Newer source code may be found on the NetBSD web site.To get the code to compile for Mac OS X, add the following line near the top of the split.c file, right among the other include statements:
#include <sys/stat.h>
This command can be then used to compile the source code:
cc -Os -o split split.c
Or use this command for a universal (PowerPC and Intel) binary:
cc -Os -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-arch i386 -arch ppc -o split split.c
The new split executable can then be installed with the commands listed below (the $ is the command prompt; don't copy and paste it). Notice that the Apple-provided split utility is renamed in case you need it in the future:
$ sudo mv /usr/bin/split /usr/bin/split.apple
$ sudo cp split /usr/bin/split
$ sudo chmod ugo-w /usr/bin/split
$ sudo chmod ugo+rx /usr/bin/split
$ sudo chown root:wheel /usr/bin/split
[robg adds: I tried this on my Intel Mac, compiling a Universal binary, and it worked fine. You'll need the Developer Tools installed to do this.]
•
[36,542 views]

