1

I want to split a file into 'n' chunks, the suffixes should be of 'a' length and should using numeric suffixes starting from number 'd'.

e.g. n = 10, a=4, d=5, As all options look correct and I tried the below

split -n10 -a4 -d5 somefile
split: cannot split in more than one way
Try 'split --help' for more information.

It gives the above error. The options look fine to me as per the man page

-a, --suffix-length=N
          generate suffixes of length N (default 2)

-d, --numeric-suffixes[=FROM]
          use numeric suffixes instead of alphabetic; FROM changes the start value (default 0)

-n, --number=CHUNKS
          generate CHUNKS output files; see explanation below

What could be the reason for the error? How can I achieve the stated goal?

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
mtk
  • 27,530
  • 35
  • 94
  • 130

1 Answers1

5

The reason this command fails (even the one with the fixed typo) is that it is syntactically wrong.

split -n10 -a4 -d5 somefile

The -d flag does not take a numeric argument. (Contrast this with the long version --numeric-suffixes which can.) See the split invocation for the details that are unfortunately omitted from the derived man page.

Use this instead

split -n10 -a4 --numeric-suffixes=5 somefile
Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • 1
    Thanks, but by the time i already file a bug on the mailing list. :) – mtk Aug 26 '15 at 21:11
  • 2
    Yes short options can't take an optional arg for back wards compat and operational reasons. Note also since coreutils v8.24 the man page links directly to the online info page, which the canonical source is now the simpler URL http://www.gnu.org/software/coreutils/split – Pádraig Brady Aug 26 '15 at 21:12