Sponsored Content
Top Forums Shell Programming and Scripting Split File Based on Line Number Pattern Post 302241868 by shankster on Tuesday 30th of September 2008 01:26:12 PM
Old 09-30-2008
Thanks to both of you for your input. I really don't know what I'm doing when it comes to UNIX, so I just try to piece tidbits together. I ended up using ERA's approach in the second posting. It was similar to what I had already put together, and made sense. JOEYG, I'm sure your appraoch would work as well, and I appreciate your input.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split a file based on a pattern

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)
Discussion started by: Mish_99
4 Replies

2. Shell Programming and Scripting

split XML file into multiple files based on pattern

Hello, I am using awk to split a file into multiple files using command: nawk '{ if ( $1 == "<process" ) { n=split($2, arr, "\""); file=arr } print > file }' processes.xml <process name="Process1.process"> ... (3 Replies)
Discussion started by: chiru_h
3 Replies

3. Shell Programming and Scripting

Split a file based on pattern and size

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)
Discussion started by: jl487
2 Replies

4. Shell Programming and Scripting

Split the file based on pattern

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)
Discussion started by: sol_nov
2 Replies

5. UNIX for Dummies Questions & Answers

Split a huge 7 GB File Based on Pattern into 4 files

Hi, I have a Huge 7 GB file which has around 1 million records, i want to split this file into 4 files to contain around 250k messages each. Please help me as Split command cannot work here as it might miss tags.. Format of the file is as below <!--###### ###### START-->... (6 Replies)
Discussion started by: KishM
6 Replies

6. Shell Programming and Scripting

How to split a file based on pattern line number?

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)
Discussion started by: bhaskar v
10 Replies

7. UNIX for Dummies Questions & Answers

Split file based on number of blank lines

Hello All , I have a file which needs to split based on the blank lines Name ABC Address London Age 32 (4 blank new line) Name DEF Address London Age 30 (4 blank new line) Name DEF Address London (8 Replies)
Discussion started by: Pratik4891
8 Replies

8. Shell Programming and Scripting

Split a text file into multiple pages based on pattern

Hi, I have a text file (attached the sample). I have also, attached the way the way the files need to be split. We get this file, that will either have 24 Jurisdictions, or will miss some and retain some. Like in the attached sample file, there are only Jurisdictions 03,11,14,15, 20 and 30.... (3 Replies)
Discussion started by: ebsus
3 Replies

9. UNIX for Advanced & Expert Users

Split one file to many based on pattern

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

10. Shell Programming and Scripting

Split File based on number of rows

Hi I have a requirement, where i will receive multiple files in a folder (say: /fol1/fol2/). There will be at least 14 to 16 files. The size of the files will different, some may be 80GB or 90GB, some may be less than 5 GB (and the size of the files are very unpredictable). But the names of the... (10 Replies)
Discussion started by: kpk_ds
10 Replies
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)
All times are GMT -4. The time now is 10:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy