In GNU/Linux in order to split file into 4 equal chunks we can do something like:

split temp -n 4 PREFIX_

But seems like the macOS' BSD version of split utility doesn't have -n option. What would be the analog of GNU split command in macOS?

  • well it's actually macos high sierra
    – Drew
    May 10, 2018 at 23:17

2 Answers 2


Unfortunately MacOS contains crippled BSD versions of coreutils. Head also does not support negative byte counts, while it's GNU analog allows to do something like head -c -1.

I ended up installing GNU version of coreutils on MacOS:

brew install coreutils

This installs all the coreutils including split and head with prefix g. So now I can do:

gsplit ${file} -n 4 PREFIX_


ghead -c -1 ${file}

You could find the size of the file and divide it by 4 and use MacOS's split -b on the number of bytes instead. I don't have a way to test this, but loosely:

size=$(stat -f '%z' "$myfile")
let part=size/4
[ "$part" = 0 ] && part=1
split -b "$part" "$myfile" ...

I don't know what happens when the size is under 4 bytes and you say split -b 0, so make it 1. See the man pages split and stat.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .