Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just tried to run a simple shell script on my Readynas server running Debian, and it appears that the split command is not available.

This is a server which I can't fiddle too much with, so if there's a way to get split running without risk of breaking other native ReadyNAS features, I would be super happy.


share|improve this question
up vote 5 down vote accepted

split is a standard utility, included in the coreutils package. This package has the priority “required” (and is marked “essential”), so a normal Debian installation would have it.

I guess your server is running BusyBox utilities. BusyBox is a suite of utilities designed for systems with little disk space or little memory. Many of its features are optional, and Debian's normal BusyBox package doesn't include the split utility (presumably because it isn't used often).

You can emulate some uses of split with the head utility and a bit of shell programming. Here's a quick and dirty script to split the input into fixed-sized chunks:

i=1000000001          # Below we'll strip away the leading 1; this is
                      # a trick to have leading zeroes in the file names.
prefix=$1             # The files will be called ${prefix}000000001, etc.
chunk_size=$2         # in bytes, or 42k or 42m for kB and MB respectively
  head -q -c "$chunk_size" >"$prefix${i#1}"
  [ -s "$prefix${i#1}" ]   # Stop when we make an empty chunk.
rm "$prefix${i#1}"         # Remove the last, zero-sized chunk.

Store that script as simple_split. Usage example:

tar -cf - /big/dir | simple_split foo.tar- 1m

This command creates 1MB-sized files called foo.tar-000000001, foo.tar-000000002, etc. You can assemble them with cat; note that thanks to the fixed-width format of the numbers, the files are ordered in lexical order of their names.

cat foo.tar-????????? | tar -tf -
share|improve this answer
Hi Giles. Thanks a lot for your answer - it clears up a lot of questions. How would I use your suggested snippet? Put it in a shell script and call it like I would call split? I.e tar .... | mysplit ? – Industrial Sep 25 '11 at 21:11
@Industrial Test it (I typed this directly in my browser), adapt it a bit, and then yes, feed it input on its standard input. – Gilles Sep 25 '11 at 21:14
Hi Giles. Please bear with me -I am far from good at this. I put the snippet as a file in /bin and tried piping tar to it, but it creates two files, one zero-byte and one file containing a list of the files in the tarball, which stays the original size. – Industrial Sep 26 '11 at 9:48
@Industrial I've updated my script a bit and added a usage example. – Gilles Oct 3 '11 at 22:40
A bit? That's fantastic! :) Thanks a lot Giles – Industrial Oct 4 '11 at 7:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.