mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-21 08:24:10 +01:00
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
This commit is contained in:
parent
04d9e255df
commit
a6dd1c93f4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=161172
@ -32,7 +32,7 @@
|
||||
.\" @(#)split.1 8.3 (Berkeley) 4/16/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd August 9, 2006
|
||||
.Dd August 10, 2006
|
||||
.Dt SPLIT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -46,7 +46,7 @@
|
||||
.Nm
|
||||
.Fl b Ar byte_count Ns
|
||||
.Oo
|
||||
.Cm k Ns | Ns Cm m
|
||||
.Cm K Ns | Ns Cm k Ns | Ns Cm M Ns | Ns Cm m Ns | Ns Cm G Ns | Ns Cm g
|
||||
.Oc
|
||||
.Op Fl a Ar suffix_length
|
||||
.Op Ar file Op Ar prefix
|
||||
@ -77,20 +77,31 @@ The options are as follows:
|
||||
Use
|
||||
.Ar suffix_length
|
||||
letters to form the suffix of the file name.
|
||||
.It Fl b Ar byte_count Ns Op Cm k Ns | Ns Cm m
|
||||
.It Fl b Ar byte_count Ns Op Cm K Ns | Ns Cm k Ns | Ns Cm M Ns | Ns Cm m Ns | Ns Cm G Ns | Ns Cm g
|
||||
Create smaller files
|
||||
.Ar byte_count
|
||||
bytes in length.
|
||||
If
|
||||
.Cm k
|
||||
or
|
||||
.Cm K
|
||||
is appended to the number, the file is split into
|
||||
.Ar byte_count
|
||||
kilobyte pieces.
|
||||
If
|
||||
.Cm m
|
||||
or
|
||||
.Cm M
|
||||
is appended to the number, the file is split into
|
||||
.Ar byte_count
|
||||
megabyte pieces.
|
||||
If
|
||||
.Cm g
|
||||
or
|
||||
.Cm G
|
||||
is appended to the number, the file is split into
|
||||
.Ar byte_count
|
||||
gigabyte pieces.
|
||||
.It Fl l Ar line_count
|
||||
Create smaller files
|
||||
.Ar line_count
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user