Search the web
Sign In
New User? Sign Up
geeksthatgawk · for GNU Awk questions & discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
msplit   Message List  
Reply | Forward Message #47 of 221 |
This is the msplit script that splits a unix mailbox file into
many separate files. Could someone please help me translating
it to gawk?

Daniel



msplit.pl

#!/usr/bin/perl

#$fname = $ARGV[0];
#$num = $ARGV[1];
#$prefix = $ARGV[2];
#$suffix = $ARGV[3];

$fname = shift;
$num = shift;
$prefix = shift;
$suffix = shift;

$nmsgs = 0;
$filenum = 0;
$ofile = $prefix . sprintf("%04d",$filenum) . $suffix;
open(OFILE,">" . $ofile);
open(INFILE,"<" . $fname);
while (<INFILE>) {
if(/^From /){
$nmsgs = $nmsgs + 1;
if ($nmsgs > $num) {
$filenum = $filenum + 1;
$ofile = $prefix . sprintf("%04d",$filenum) . $suffix;
close OFILE;
open(OFILE,">" . $ofile);
$nmsgs = 0;
}
}
print OFILE $_;
}
close OFILE;
close INFILE;




Wed Dec 11, 2002 7:07 pm

daniel_ajoy
Offline Offline
Send Email Send Email

Forward
Message #47 of 221 |
Expand Messages Author Sort by Date

This is the msplit script that splits a unix mailbox file into many separate files. Could someone please help me translating it to gawk? Daniel msplit.pl ...
Daniel Ajoy
daniel_ajoy
Offline Send Email
Dec 11, 2002
7:30 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help