How to set starting index in split command in linux ? How to set starting index in split command in linux ? unix unix

How to set starting index in split command in linux ?


Since coreutils release 8.16 (2012-03-26) you can do:

split --numeric=1 -l 100 largeFile.txt smallFile.txt.


Since you said Linux that means split comes from GNU coreutils. If you look at the source for split the code handling the -d / --numeric-suffixes option is setup to take an optional argument but the call to getopt_long does not enable one. Perhaps due to compatibility reasons? You should mail them and ask.

http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob_plain;f=src/split.c;hb=HEAD

@@ -1153,7 +1153,7 @@ main (int argc, char **argv)       int this_optind = optind ? optind : 1;       char *slash;-      c = getopt_long (argc, argv, "0123456789C:a:b:del:n:u",+      c = getopt_long (argc, argv, "0123456789C:a:b:d:el:n:u",                        longopts, NULL);       if (c == -1)         break;

This patch enables the optional number argument to be handled. Then you can invoke split as:

split -d 1 foo foo.split.

And the numbers start from 1, not 0.

You can get the source from http://www.gnu.org/software/coreutils/ and apply this change yourself and use it locally if you like.