Quote:
>>I am in need of routine that will allow me to specify lrecl of new
>>file being read from another file with an extended lrecl. Also allow
>>me to specify names of both existing and new file. Can anyone help???
>Perhaps.
>What is lrecl? It isn't an awk (or unix) term I've heard of.
<snip>
Maybe inapt, but LRECL is an IBM mainframe term meaning logical record
length. You've lived a blessed life if LRECL, JCL, DSN and DDN aren't
seared into your memory.
To the original poster: are you doing this on a mainframe? If so, would
you be using awk?? If so, then you should be able to read each record
from the file with the extended record length into awk's $0 and write
sequential substrings of specified maximum length to the new file with
the shorter record length. Presumably you'd want to leave words and
numbers intact, so you should split into substrings after the rightmost
whitespace character to the left of your output record length.
BEGIN { newlen = 72 }
{ s = $0
do {
ss = substr(s, 1, newlen)
sub(/[^ \t]*$/, "", ss)
printf("%-*s", newlen, ss)
s = substr(s, length(ss))
} while (length(s))
Quote:
}
It's been a while since I've done this, so I'm not sure I don't need to
include a newline (or EBCDIC equivalent) at the ends of the new records.
If you have a mainframe awk, you may have a mainframe version of unix's
fold command, which would be better suited to this task. Then, since
this isn't exactly an uncommon operation on mainframes, isn't there a
system command or standard REXX or CLIST script to do this?
If you're not on a mainframe, then odds are very good you have fold. Use
it to do this instead of awk.
Sent via Deja.com http://www.deja.com/
Before you buy.