![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to split a file | aarif | UNIX for Dummies Questions & Answers | 2 | 03-01-2008 03:36 PM |
| Split files using Csplit | savitha | UNIX for Dummies Questions & Answers | 7 | 12-01-2007 11:55 AM |
| Split file | mpang_ | Shell Programming and Scripting | 3 | 09-12-2006 08:37 PM |
| Split a file | Reza Nazarian | UNIX for Dummies Questions & Answers | 1 | 08-09-2006 06:01 AM |
| multiple pattern split in perl | umen | Shell Programming and Scripting | 3 | 08-01-2006 02:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Split a file with no pattern -- Split, Csplit, Awk
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: Code:
split -l 3000000 filename.txt I am also trying awk and I know it will be very fast and simple. I read the forum and they are all splitting the files on a specific pattern and I don't require any pattern. Please give me your input on this.. |
|
||||
|
If disk i/o is not making split "too slow" then try awk. But you should consider that a big I/O request queue length on that filesystem is a likely candidate for slow splitting, rather than split being a bad performer.
awk version of split: Code:
awk ' {
if(NR<300000) { print $0 > "smallfile1"}
if (NR>300000 && NR < 600000) { print $0 > "smallfile2" }
if (NR>60000) {print $0 > "smallfile3" }
}' bigfile
|
|
||||
|
Thank you Radoulov...When I ran your code, it is saying file1, file2 or file3 is not found. It seems like the code is assuming that those are the input files. However, Jim's code is working fine.
The whole environment is on Windows. But I am using MKS Tool kit and invoking bash shell to execute awk. Never worked on Windows before and it is not quite nice.. |
|
|||||
|
Quote:
just realized I misread your question (you don't want to pass multiple input files). |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|