diff options
author | keramida <keramida@FreeBSD.org> | 2006-08-10 10:41:47 +0000 |
---|---|---|
committer | keramida <keramida@FreeBSD.org> | 2006-08-10 10:41:47 +0000 |
commit | cd184a0ca173a9d4626e0a586a52534a1eb56863 (patch) | |
tree | e9178db3548ea9d43dd71ffd1b7cff64a03b3dfa /usr.bin/split/split.c | |
parent | a32a200792ebecceec10edd874e410c1913c939c (diff) | |
download | FreeBSD-src-cd184a0ca173a9d4626e0a586a52534a1eb56863.zip FreeBSD-src-cd184a0ca173a9d4626e0a586a52534a1eb56863.tar.gz |
Add support for splitting at gigabyte boundaries. [1]
Also make both lowercase and uppercase suffix letters work
as byte-count suffixes, i.e. the following two commands are
equivalent now:
% split -b 4m foo
% split -b 4M foo
Submitted by: Roman Divacky [1]
Lots of help by: cperciva
Reviewed by: cperciva
MFC after: 1 week
Diffstat (limited to 'usr.bin/split/split.c')
-rw-r--r-- | usr.bin/split/split.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index 71b47c7..d7936b0 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -116,14 +116,15 @@ main(int argc, char **argv) case 'b': /* Byte count. */ errno = 0; if ((bytecnti = strtoimax(optarg, &ep, 10)) <= 0 || - (*ep != '\0' && *ep != 'k' && *ep != 'm') || - errno != 0) + strchr("kKmMgG", *ep) == NULL || errno != 0) errx(EX_USAGE, "%s: illegal byte count", optarg); - if (*ep == 'k') + if (*ep == 'k' || *ep == 'K') scale = 1024; - else if (*ep == 'm') + else if (*ep == 'm' || *ep == 'M') scale = 1024 * 1024; + else if (*ep == 'g' || *ep == 'G') + scale = 1024 * 1024 * 1024; else scale = 1; if (bytecnti > OFF_MAX / scale) @@ -336,7 +337,7 @@ usage(void) { (void)fprintf(stderr, "usage: split [-l line_count] [-a suffix_length] [file [prefix]]\n" -" split -b byte_count[k|m] [-a suffix_length] [file [prefix]]\n" +" split -b byte_count[K|k|M|m|G|g] [-a suffix_length] [file [prefix]]\n" " split -p pattern [-a suffix_length] [file [prefix]]\n"); exit(EX_USAGE); } |