I believe your number of lines which you need in output split files are NOT even. So I am coming up here with an approach where one could mention the line numbers when they want to generate a new output file. Let's say your own example posted one, you need first 20 lines in file1, then next 10 lines to file2, next 10 lines to file3, next 10 lines to file4 and then next 40 lines to file5. If this is the case then could you please try following(I have NOT tested it, I am cooking right now, I am pretty sure it should WORK ).
NOTE: Point to be noted here is split("20,10,10,10,40",array,",") code's part is responsible for mentioning number of lines in output file so please be sure you are providing proper values here.
NOTE2: Also I am closing the output files with close(file) statement to avoid errors like
Hello all.
Sorry, I know this question is similar to many others, but I just can seem to put together exactly what I need.
My file is tab delimitted and contains approximately 1 million rows. I would like to send lines 1,4,& 7 to a file. Lines 2, 5, & 8 to a second file. Lines 3, 6, & 9 to... (11 Replies)
Hi, Please help on this. i want split the below file(11020111.CLT) to more files with some condition. :b:
1) %s stating of the report
2) %e ending of the report
example starting of the report:
%sAEGONCA| |MUMBAI | :EXPC|N|D
ending of the report
%eAEGONCA| |MUMBAI | :EXPC
3)so the... (10 Replies)
I have a problem which I would like to solve by using UNIX power and inspired minds around world. Here is the problem
I have a text file and it has data as follows
1X.....................1234567890123456789T1234598765XT1 (header)
1Z01............(sub HEADER)
P100001............
Q1........... (4 Replies)
Dear shell experts,
I would like to spilt a txt file into small ones. However, I did not know how to program use shell. If someone could help, it is greatly appreciated!
Specifically, I supposed there is file named A.txt. The content of the file likes this:
Subject run condtion ACC time... (3 Replies)
I want to add/append the info in the following format to my.txt file.
20130702|abcd20130702.txt FN|SN|DOB
I tried the below script but it throws me some exceptions.
<#!/bin/sh
dt = date '+%y%m%d'members;
echo $dt+|+members+$dt;
/usr/bin/awk -f
BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Can u pls advise the unix command as I have a file which contain the records in the below format
333434
435435
435443
434543
343536
Now the total line count is 89380 , now i want to create a separate
I am trying to split my large big file into small bits using the line... (2 Replies)
Hi
i have requirement like below
M <form_name> sdasadasdMklkM
D ......
D .....
M form_name> sdasadasdMklkM
D ......
D .....
D ......
D .....
M form_name> sdasadasdMklkM
D ......
M form_name> sdasadasdMklkM
i want split file based on line number by finding... (10 Replies)
Hi All,
I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom.
from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Hi All
Is there a way to export every line into new txt file where by the title of each txt output are same as the line ?
I have this txt files containing names:
Kandra Vanhooser
Rhona Menefee
Reynaldo Hutt
Houston Rafferty
Charmaine Lord
Albertine Poucher
Juana Maes
Mitch Lobel... (2 Replies)
I Have a large file with 24hrs log in the below format.i need to split the large file in to 24 small files on one hour based.i.e ex:from 09:55 to 10:55,10:55-11:55
can any one help me on this.!
... (20 Replies)
Discussion started by: Raghuram717
20 Replies
LEARN ABOUT OSF1
split
split(1) General Commands Manual split(1)NAME
split - Splits a file into pieces
SYNOPSIS
Current syntax
split [-l line_count] [-a suffix_length] [file | -] [prefix]
split -b n [k|m] [-a suffix_length] [file | -] [prefix]
Obsolescent syntax
split [-number] [-a suffix_length] [file | -] [prefix]
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
split: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Uses suffix_length letters to form the suffix portion of the file names of the split file. If -a is not specified, the default suffix
length is two letters. If the sum of the prefix and the suffix arguments would create a file name exceeding NAME_MAX bytes, an error
occurs. In this case, split exits with a diagnostic message and no files are created. Split a file into pieces n bytes in size. Split a
file into pieces n kilobytes (1024 bytes) in size. Split a file into pieces n megabytes (1048576 bytes) in size. Specifies the number of
lines in each output file. The line_count argument is an unsigned decimal integer. The default value is 1000. If the input does not end
with a newline character, the partial line is included in the last output file. Specifies the number of lines in each output file. The
default is 1000 lines per output file. If the input does not end with a newline character, the partial line is included in the last output
file. (Obsolescent)
OPERANDS
The pathname of the file to be split.
If you do not specify an input file, or if you specify -, the standard input is used.
DESCRIPTION
The split command reads file and writes it in number-line pieces (default 1000 lines) to a set of output files.
The size of the output files can be modified by using the -b or -l options. Each output file is created with a unique suffix consisting of
exactly suffix lowercase letters from the POSIX locale. The letters of the suffix are used as if they were a base-26 digit system, with
the first suffix to be created consisting of all a characters, the second with b replacing the last a etc., until a name of all zs is cre-
ated. By default, the names of the output files are x, followed by a two-character suffix from the character set as described above,
starting with aa, ab, ac, etc., and continuing until the suffix zz, for a maximum of 676 files.
The value of prefix cannot be longer than the value of NAME_MAX from <limits.h> minus two.
If the number of files required is greater than the maximum allowed by the effective suffix length (such that the last allowable file would
be larger than the requested size), split fails after creating the last possible file with a valid suffix. The split command will not
delete the files it created with valid suffixes. If the file limit is not exceeded, the last file created contains the remainder of the
input file and thus might be smaller than the requested size.
EXIT STATUS
The following exit values are returned: Successful completion. An error occurred.
EXAMPLES
To split a file into 1000-line segments, enter: split book
This splits book into 1000-line segments named xaa, xab, xac, and so forth. To split a file into 50-line segments and specify the
file name prefix, enter: split -l50 book sect
This splits book into 50-line segments named sectaa, sectab, sectac, and so forth.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of split: Provides a default value for the internationalization variables that are
unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari-
ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value,
overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes
of text data as characters (for example, single-byte as opposed to multibyte characters in arguments and input files). Determines the
locale for the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the
processing of LC_MESSAGES.
SEE ALSO
Commands: bfs(1), csplit(1)
Standards: standards(5)split(1)