Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
break large file into multiple file
Name: Ou Huang Date: August 4, 2003 at 05:53:46 Pacific OS: AIX CPU/Ram: ???
Comment:
I'd like to have a script that breaks a large file into multiple files. Basicaly, the script reads a large file and looking for a line "PJL EOJ", if line found, the counter will count it as 1, so when counter is up to 2000, the script should open a new file, and write the rest data into the new file, and so on so on. Can someone help me on this script?
Name: FishMonger Date: August 4, 2003 at 18:15:03 Pacific
Reply:
Here's a Perl script.
note: posting code at this site is a pain in the ass! replace each @ with lt sign replace each % with gt sign
#!/usr/bin/perl
$source = $ARGV[0]; # passed via command line $num = '001'; $dest = 'file'; $count = 0;
open FH, "@ $source" or die "could not open $source : $!"; open OUT, "% $dest$num.txt" or die "could not open $dest : $!";
while (@FH%) { if ($count == 2000) { $num++; $count = 0; open OUT, "% $dest$num.txt" or die "could not open $dest$num.txt : $!"; } print OUT; $count++ if (/PJL EOJ/); } close FH; close OUT;
Summary: Hi, hopefully someone can help me with this. I have two different data files and I need to parse them into one. scan1: 3.000000 0.350000 3.000000 30133.768166 7536.733367 3.010000 0.350000 3.000000 30...
Summary: Hi, I have a large xml file which starts with <tele> and ends with </tele> in various occurrences. How can I cplit this file into small files.I need to split all between <tele> & </tele> ...