It is useful to know how to do custom splitting with awk, perl, etc., but one can often use utilities that are already present, such as csplit:
Producing:
See man csplit for details (Solaris man page has some examples, unlike the man page in Linux) ... cheers, drl
I have gone through all the threads in the forum and tested out different things. I am trying to split a 3GB file into multiple files. Some files are even larger than this.
For example:
split -l 3000000 filename.txt
This is very slow and it splits the file with 3 million records in each... (10 Replies)
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)
Dear all,
I have a large file which is composed of 8000 frames, what i would like to do is split the file into 8000 single files names file.pdb.1, file.pdb.2 etc etc
each frame in the large file is seperated by a "ENDMDL" flag so my thinking is to use this flag a a point to split the files... (4 Replies)
Hello All,
I have a file which is having below type of data,
Jul 19 2011 | 123456
Jul 19 2011 | 123456
Jul 20 2011 | 123456
Jul 20 2011 | 123456
Here I wanted to grep for date pattern as below, so that it should only grep "Jul 20" OR "Jul ... (9 Replies)
I have a binary (hex) file I need to parse to get some data which are encoded this way:
.* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL
By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Hello, I have a large file (2GB) that I would like to split based on pattern and size.
I've used the following command to split the file (token is "HELLO")
awk '/HELLO/{i++}{print > "file"i}' input.txt
and the output is similar to the following (i included filesize in KB):
10 ... (2 Replies)
Hi ,
I have huge files around 400 mb, which has clob data and have diffeent scenarios:
I am trying to pass scenario number as parameter and and get required modified file based on the scenario number and criteria.
Scenario 1:
file name : scenario_1.txt
... (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 ,
I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows.
# diff mir_lex.c.modified mir_lex.c.orig
3209c3209
< if(yy_current_buffer -> yy_is_our_buffer == 0) {
---
>... (5 Replies)
Hello All,
I have records in a file in a pattern A,B,B,B,B,K,A,B,B,K
Is there any command or simple logic I can pull out records into multiple files based on A record? I want output as
File1: A,B,B,B,B,K
File2: A,B,B,K (9 Replies)
Discussion started by: deal1dealer
9 Replies
LEARN ABOUT HPUX
csplit
csplit(1) General Commands Manual csplit(1)NAME
csplit - context split
SYNOPSIS
prefix] number] file arg1 [...argn]
DESCRIPTION
reads file, separates it into n+1 sections as defined by the arguments arg1 ... argn, and places the results in separate files. The maxi-
mum number of arguments (arg1 through argn) allowed is 99 unless the option is used to allow for more output file names. If the option is
specified, the resulting filenames are through prefixNN where NN is the two-digit value of n using a leading zero if n is less than 10. If
the option is not specified, the default filenames through are used. file is divided as follows:
Default Prefixed
Filename Filename Contents
-----------------------------------------------------
xx00 prefix00 From start of file up to (but
not including) the line refer-
enced by arg1.
xx01 prefix01 From the line referenced by
arg1 up to the line referenced
by arg2.
.
.
.
xxNN prefixNN From the line referenced by
argn to end of file.
If the file argument is standard input is used.
supports the Basic Regular Expression syntax (see regexp(5)).
Options
recognizes the following options:
Suppress printing of all character counts
normally prints the character counts for each file created).
Leave previously created files intact
normally removes created files if an error occurs).
Name created files
through prefixNN (default is through
The output file name suffix will use
number digits instead of the default This allows creation of more than 100 output files.
Arguments (arg1 through argn) to can be any combination of the following:
Create a file containing the section from the current line
up to (but not including) the line matching the regular expression regexp. The new current line becomes the line
matching regexp.
Create a file containing the section from the current line
up to (but not including) the nth before or after the line matching the regular expression regexp. (e.g., The new
current line becomes the line matching plus or minus n lines.
equivalent to except that no file is created for the section.
line_number Create a file from the current line up to (but not including) line_number. The new current line becomes line_number.
Repeat argument.
This argument can follow any of the above argument forms. If it follows a regexp argument, that argument is applied
num more times. If it follows line_number, the file is split every line_number lines for num times from that point
until end-of-file is reached or num expires.
Repeats previous operand as many times as necessary to
finish input.
Enclose in appropriate quotes all regexp arguments containing blanks or other characters meaningful to the shell. Regular expressions must
not contain embedded new-lines. does not alter or remove the original file; it is the user's responsibility to remove it when appropriate.
EXTERNAL INFLUENCES
Environment Variables
determines the collating sequence used in evaluating regular expressions.
determines the characters matched by character class expressions in regular expressions.
determines the language in which messages are displayed.
If or or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty
variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization
variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
DIAGNOSTICS
Messages are self explanatory except for:
which means that the given argument did not reference a line between the current position and the end of the file. This warning also
occurs if the file is exhausted before the repeat count is.
EXAMPLES
Create four files, through After editing the ``split'' files, recombine them back into the original file, destroying its previous contents.
Perform editing operations
Split a file at every 100 lines, up to 10,000 lines (100 files). The option causes the created files to be retained if there are fewer
than 10,000 lines (an error message is still printed).
Assuming that follows the normal C coding convention of terminating routines with a at the beginning of the line, create a file containing
each separate C routine (up to 21) in
SEE ALSO sh(1), split(1), environ(5), lang(5), regexp(5).
STANDARDS CONFORMANCE csplit(1)