xref: /netbsd-src/usr.bin/split/split.1 (revision 5e25f4bb07b0128a3c25bd0907bac149adfbf9cb)
1.\"	$NetBSD: split.1,v 1.17 2023/02/14 18:11:55 jschauma Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993, 1994
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	@(#)split.1	8.3 (Berkeley) 4/16/94
31.\"
32.Dd February 14, 2023
33.Dt SPLIT 1
34.Os
35.Sh NAME
36.Nm split
37.Nd split a file into pieces
38.Sh SYNOPSIS
39.Nm
40.Op Fl a Ar suffix_length
41.Oo
42.Fl b Ar byte_count Ns Oo Li k|m Oc |
43.Fl l Ar line_count |
44.Fl n Ar chunk_count
45.Oc
46.Op Ar file Op Ar name
47.Sh DESCRIPTION
48The
49.Nm
50utility reads the given
51.Ar file
52and breaks it up into files of 1000 lines each.
53If
54.Ar file
55is a single dash or absent,
56.Nm
57reads from the standard input.
58.Ar file
59itself is not altered.
60.Pp
61The options are as follows:
62.Bl -tag -width Ds
63.It Fl a
64Use
65.Ar suffix_length
66letters to form the suffix of the file name.
67.It Fl b
68Create smaller files
69.Ar byte_count
70bytes in length.
71If
72.Ql k
73is appended to the number, the file is split into
74.Ar byte_count
75kilobyte pieces.
76If
77.Ql m
78is appended to the number, the file is split into
79.Ar byte_count
80megabyte pieces.
81.It Fl l
82Create smaller files
83.Ar line_count
84lines in length.
85.It Fl n
86Split file into
87.Ar chunk_count
88smaller files.
89.El
90.Pp
91If additional arguments are specified, the first is used as the name
92of the input file which is to be split.
93If a second additional argument is specified, it is used as a prefix
94for the names of the files into which the file is split.
95In this case, each file into which the file is split is named by the
96prefix followed by a lexically ordered suffix using
97.Ar suffix_length
98characters in the range
99.Dq Li a-z .
100If
101.Fl a
102is not specified, two letters are used as the initial
103suffix.
104If the output does not fit into the resulting number
105of files, then the suffix length is automatically
106extended as needed such that all output files continue
107to sort in lexical order.
108.Pp
109If the
110.Ar name
111argument is not specified,
112.Ql x
113is used.
114.Sh STANDARDS
115The
116.Nm
117utility conforms to
118.St -p1003.1-2001 .
119.Sh HISTORY
120A
121.Nm
122command appeared in
123.At v6 .
124.Pp
125The
126.Fl a
127option was introduced in
128.Nx 2.0 .
129Before that, if
130.Ar name
131was not specified,
132.Nm
133would vary the first letter of the filename
134to increase the number of possible output files.
135The
136.Fl a
137option makes this unnecessary.
138