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...
Show off your group to the world. Share a photo of your group with us.

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
Re: [Geeks that Gawk] msplit   Message List  
Reply | Forward Message #49 of 221 |
Re: [Geeks that Gawk] msplit

On 11 Dec 2002 at 21:06, Peter S Tillier wrote:

> Literal translation follows (untested):
>

You are the geek! :)
It worked exactly like "msplit.pl".
I made some modifications. Code follows:


#!/bin/awk

# msplit splits a unix mailbox file into many separate files.
# msplit.awk
# Run as:
# msplit.awk filename num prefix suffix

BEGIN {
num = ARGV[2]
prefix = ARGV[3]
suffix = ARGV[4]
ofile = prefix sprintf("%04d",filenum) suffix
}

/^From / {
nmsgs ++
if (nmsgs > num) {
filenum++
ofile = prefix sprintf("%04d",filenum) suffix
close(ofile)
nmsgs = 0
}
}

{ print > ofile }




Daniel

PS. I'm not sure how the "num" argument can be used...




Thu Dec 12, 2002 5:21 am

daniel_ajoy
Offline Offline
Send Email Send Email

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

... Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com...
Peter S Tillier
peter_tillier
Offline Send Email
Dec 11, 2002
9:06 pm

... You are the geek! :) It worked exactly like "msplit.pl". I made some modifications. Code follows: #!/bin/awk # msplit splits a unix mailbox file into many...
Daniel Ajoy
daniel_ajoy
Offline Send Email
Dec 12, 2002
5:21 am

... Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com...
Peter S Tillier
peter_tillier
Offline Send Email
Dec 12, 2002
7:03 am
Advanced

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