split(1) General Commands Manual split(1)Name
split - split file into smaller files
Syntax
split [-n] [file [name]]
Description
The command reads file and writes it in n-line pieces (default 1000), as many as necessary, onto a set of output files. The name of the
first output file is name with aa appended, and so on lexicographically. If no output name is given, x is default.
If no input file is given, or if - is given in its stead, then the standard input file is used.
Options
- Uses standard input.
-n Writes specified number of lines to each output file. Default is 1000.
split(1)
Check Out this Related Man Page
SPLIT(1) BSD General Commands Manual SPLIT(1)NAME
split -- split a file into pieces
SYNOPSIS
split [-a suffix_length] [-b byte_count[k|m]] [-l line_count] [-p pattern] [file [name]]
DESCRIPTION
The split utility reads the given file and breaks it up into files of 1000 lines each. If file is a single dash ('-') or absent, split reads
from the standard input.
The options are as follows:
-a suffix_length
Use suffix_length letters to form the suffix of the file name.
-b byte_count[k|m]
Create smaller files byte_count bytes in length. If ``k'' is appended to the number, the file is split into byte_count kilobyte
pieces. If ``m'' is appended to the number, the file is split into byte_count megabyte pieces.
-l line_count
Create smaller files n lines in length.
-p pattern
The file is split whenever an input line matches pattern, which is interpreted as an extended regular expression. The matching line
will be the first line of the next output file. This option is incompatible with the -b and -l options.
If additional arguments are specified, the first is used as the name of the input file which is to be split. If a second additional argument
is specified, it is used as a prefix for the names of the files into which the file is split. In this case, each file into which the file is
split is named by the prefix followed by a lexically ordered suffix using suffix_length characters in the range ``a-z''. If -a is not speci-
fied, two letters are used as the suffix.
If the name argument is not specified, the file is split into lexically ordered files named with the prefix ``x'' and with suffixes as above.
ENVIRONMENT
The LANG, LC_ALL, LC_CTYPE and LC_COLLATE environment variables affect the execution of split as described in environ(7).
EXIT STATUS
The split utility exits 0 on success, and >0 if an error occurs.
SEE ALSO csplit(1), re_format(7)STANDARDS
The split utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'').
HISTORY
A split command appeared in Version 3 AT&T UNIX.
BUGS
The maximum line length for matching patterns is 65536.
BSD August 21, 2005 BSD
Hi All,
We have file structure as following. (Coma ';' delimiter file)
Header
1;...
1;...
1;...
2;...
2;...
2;...
Trailer
We need to split this file as following. (for each change in first field, after header, we need to create new file with Header and Trailer line)
Header... (21 Replies)
Hi,
i have a file like this:
1|2|3|4|5|
1|2|8|4|6|
Trailer1|||||
1|2|3|
Trailer2|||
3|4|5|6|
3|4|5|7|
3|4|5|8|
Trailer2|||
I want to generate 3 files out of this based on the trailer record. Trailer record string can be different for each file or it may be same for one or two.
No... (24 Replies)
Hello,
I have connected storedge d2 to V440 running solaris 10. I had a raid 5 volume created using VXVM software. This morning when I rebooted the system, I get below error,
Apr 2 14:21:10 servername vxvm:vxconfigd: V-5-1-9576 Split Brain. da id is 0.1, while dm id is 0.0 for dm myapp-dg01... (52 Replies)
Hello,
I have a complex problem. I have a file in which words have been joined together:
Theboy ranslowly
I want to be able to correctly split the words using a lookup file in which all the words occur:
the
boy
ran
slowly
slow
put
child
ly
The lookup file which is meant for look up... (21 Replies)
I have a file in unix with sample data as follows :
--------------------------------------------------------------
--------------------------------------------------------------
{30001002|XXparameter|Layout|$
I want this file to be splitted into different files and corresponding to the sample... (54 Replies)
Hi All,
I have user input file like below:-
emplid|empl_name|salary|hire_date
1111|gro|3000|01/01/2014
1111|ghgo|4000|01/03/2014
1111|dkguo|5000|02/01/2014
1111|ehrt|6000|01/04/2014
1111|kfgtr|8000|03/01/2014
Sometimes input file will look like below.... (21 Replies)
I need to split the file based on pattern from position 34-37 while retaining the header and trailer records in each individual split file
Also is it possible to output the TOM and PAT records in the same output file ?
I need the output file names same as xyz_pattern_Datetimestamp.txt
... (23 Replies)
How to split the file and have suffix with formatted numbers
Tried the following code
awk '{filename="split."int((NR-1)/2)".txt"; print >> filename}' split.txt
Current Result
Expected Result (21 Replies)
Hello, This is my first posting and attempt to create a loop using Unix and awk commands. So far this is what I have:
awk -F, 'BEGIN {months ="AP01"; months ="AP02"; months ="AP03";
months ="AP04"; months ="AP05"; months ="AP06";
months ="AP07"; months ="AP08"; months ="AP09";
months... (25 Replies)
Hi,
I'm receiving text data on a server trough UDP packets.
The data are encoded messages separated by blank lines, like this:
!AIVDM,1,1,,A,13FPE?PP08OG@cPH:Gi8OwwB0<0h,0*06
!AIVDM,1,1,,A,13Ebj60000wH2E:H:mKIF2GB2<17,0*49
!AIVDM,1,1,,B,4028nAAv9Kh0awESU0HRIP102D3f,0*5D
I'm using... (23 Replies)
Split large xml into mutiple files and with header and footer in file
tried below
it splits unevenly and also i need help in adding header and footer
command :
csplit -s -k -f my_XML_split.xml extrfile.xml "/<Document>/" {1}
sample xml
<?xml version="1.0" encoding="UTF-8"?><Recipient>... (36 Replies)