Can somebody provide me an example of how to do this in AWK. For
example:
My file does not have any new lines in it so I can use split. So each
line must
be 1200 bytes long than I write it out to a file. Once I write 25,000
lines to the first file I want to start writing to a second file,
third file .... until my input is exhasuted.
Thanks in advance for all who answer
(I assume you mean "can't use" above)
You can use split, of course. See the -b option.
Or you could use dd in a loop, each time starting from a different offset.
But not if you want the \n character at the end of each 1200 bytes line.
Since you're saying "lines", I'm assuning you want the \n after a 1200 bytes
line?
But for the other part, essentially what you want to do is change the name
of the output file every 25000 lines. Here's an outline of one way to do it;
you'll have to fill in details yourself
{
outputFile = "myfilename" ++fileCounter # adjust to the conventions of
your locale
for ( lineCounter = 0; lineCounter < 25000; lineCounter++ ) {
# collect 1200 bytes in a variable (I have no idea how you plan to
do this)
print my1200bytes > outputFile # this will put newlines in; use
printf() for no newlines
}
close( outputFile )
}
You'll have to add code to watch for the end of the input file. Unless it's
an exact multiple of 25000 1200-byte lines, you'll have to watch for that
inside the main loop (and then decide what you want to do with that last,
non-1200-byte line).
- Anton Treuenfels
"Stu" <beefs...@hotmail.com> wrote in message
news:dd412a85-0c75-481d...@l28g2000vba.googlegroups.com...