script to splite large file to number of small files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to splite large file to number of small files
# 1  
Old 07-14-2008
script to splite large file to number of small files

Dear All,
Could you please help me to split a file contain around 240,000,000 line to 4 files all equally likely , note that we need to maintain that the end of each file should started by start flage (MSISDN) and ended by end flag (End), also the number of the line between the start flag (MSISDN) and end flag (End) are variable.
Kindly find below sample of the lines in the file
//////////////////////////////////////////////////////
MSISDN
line1
line2
line3
line4
line5
.
.
Line36
End
MSISDN
line1
line2
line3
line4
line5
.
.
line37
End
MSISDN
.
.
//////////////////////////////////////////

Thank you in advance,
# 2  
Old 07-14-2008
If you have not known about the split command, then please have a look
Code:
man split

I hope you may need to use the -l option.
# 3  
Old 07-14-2008
This should prints the sections into file1, file2, file3 etc.:

Code:
awk '/MSISDN/{i++}{print > "file"i}'  file

Regards
# 4  
Old 07-14-2008
Dear krishmaths,

many thanks for ur relpy, unfortunately split command will not be helpfull as the source file has records and each record has lines started by MSISDN flag and Ended by End flag, but split command split the files base on number of lines or by bytes.
# 5  
Old 07-14-2008
Dear Franklin52,

Thank u for ur reply,my input file has more than 6,000,000 record ,which is mean the awk will output 6,000,000 file,my request only to split the file into 4 or 5 files.

Thank u again and waiting ur valuable contributions
# 6  
Old 07-14-2008
Quote:
Originally Posted by ahmed.gad
Dear Franklin52,

Thank u for ur reply,my input file has more than 6,000,000 record ,which is mean the awk will output 6,000,000 file,my request only to split the file into 4 or 5 files.
Not true, the awk command creates files by sections between "MSISDN" and "End". How do you want to seperate the output in 4 or 5 files? How many sections in 1 file?

Regards
# 7  
Old 07-15-2008
the number of sections in the input file (large file) are 6,000,000 section, so what i need is splitting this file to 4 or 5 files with maintaining that the section start and end in each file.
Thanks,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Split large file into 24 small files on one hour basis

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

2. Shell Programming and Scripting

Removing large number of temp files

Hi All, I am having a situation now to delete a huge number of temp files created during run times approx. 16700+ files. We have never imagined that we will get this this much big list of files during run time. It worked fine for lesser no of files in the list. But when list is huge we are... (7 Replies)
Discussion started by: mad man
7 Replies

3. Shell Programming and Scripting

Breaking large file into small files

Dear all, I have huge txt file with the input files for some setup_code. However for running my setup_code, I require txt files with maximum of 1000 input files Please help me in suggesting way to break down this big txt file to small txt file of 1000 entries only. thanks and Greetings, Emily (12 Replies)
Discussion started by: emily
12 Replies

4. Shell Programming and Scripting

Sftp large number of files

Want to sftp large number of files ... approx 150 files will come to server every minute. (AIX box) Also need make sure file has been sftped successfully... Please let me know : 1. What is the best / faster way to transfer files? 2. should I use batch option -b so that connectivity will be... (3 Replies)
Discussion started by: vegasluxor
3 Replies

5. UNIX for Dummies Questions & Answers

Delete large number of files

Hi. I need to delete a large number of files listed in a txt file. There are over 90000 files in the list. Some of the directory names and some of the file names do have spaces in them. In the file, each line is a full path to a file: /path/to/the files/file1 /path/to/some other/files/file 2... (4 Replies)
Discussion started by: inakajin
4 Replies

6. Shell Programming and Scripting

Concatenation of a large number of files

Hellow i have a large number of files that i want to concatenate to one. these files start with the word 'VOICE_' for example VOICE_0000000000 VOICE_1223o23u0 VOICE_934934927349 I use the following code: cat /ODS/prepaid/CDR_FLOW/MEDIATION/VOICE_* >> /ODS/prepaid/CDR_FLOW/WORK/VOICE ... (10 Replies)
Discussion started by: chriss_58
10 Replies

7. Shell Programming and Scripting

Script to Compare a large number of files.

I have a large Filesystem on an AIX server and another one on a Red Hat box. I have syncd the two filesystems using rsysnc. What Im looking for is a script that would compare to the two filesystems to make sure the bits match up and the number of files match up. its around 2.8 million... (5 Replies)
Discussion started by: zippdawg2001
5 Replies

8. Shell Programming and Scripting

Split large file and add header and footer to each small files

I have one large file, after every 200 line i have to split the file and the add header and footer to each small file? It is possible to add different header and footer to each file? (7 Replies)
Discussion started by: ashish4422
7 Replies

9. Shell Programming and Scripting

moving large number of files

I have a task to move more than 35000 files every two hours, from the same directory to another directory based on a file that has the list of filenames I tried the following logics (1) find . -name \*.dat > list for i in `cat list` do mv $i test/ done (2) cat list|xargs -i mv "{}"... (7 Replies)
Discussion started by: bryan
7 Replies

10. Shell Programming and Scripting

Splitting large file into small files

Hi, I need to split a large file into small files based on a string. At different palces in the large I have the string ^Job. I need to split the file into different files starting from ^Job to the last character before the next ^Job. Also all the small files should be automatically named.... (4 Replies)
Discussion started by: dncs
4 Replies
Login or Register to Ask a Question