-d option for split is illegal on OS X 10.9

I have bash script that works on Ubuntu but for OS X 10.9 i get the error for split command:

split -b 1000000 -a 3 -d $F $F && rm $F || { echo "Error: 'split' command not installed" ; exit 1 ; }

split: illegal option -- d .

According to the split man page, -d is

   -d, --numeric-suffixes
          use numeric suffixes instead of alphabetic

Is there workaround for this?


Solution 1:

The GNU version of split is different to the OS X version of split.

OS X is based on BSD Unix, and Linux (often referred to as GNU/Linux) uses the GNU toolset.

The GNU version of split is part of the coreutils, and the good news is that these are available in MacPorts. If you have MacPorts installed, you can install the coreutils port using the command:

sudo port install coreutils

This installs the GNU core utilities (including split) with a g prefix, so you call split using the command gsplit.