I was wondering someone might be able to push me in the right direction, I am writing a script to modify fixed-width spool files, As you can see below the original spool file broke a single line into two for printability sake.
I have had been able do the joins using sed, the thing I am stumbling on is how to properly pad the description field (ex. PODIATRY) to the maximum allowable position so that visually everything still adds up.
I would love to see a sed or awk solution or suggestion, my programming skills aren't as strong as most but I would love to see an efficient solution that I could sink my teeth into and figure out why it does what it does. Thanks in advance!
this is described in 'man -s 3C printf' (at least on Solaris):
A field width, or precision, or both may be indicated by an
asterisk (*) . In this case, an argument of type int sup-
plies the field width or precision. Arguments specifying
field width, or precision, or both must appear in that order
before the argument, if any, to be converted. A negative
field width is taken as a - flag followed by a positive
field width. A negative precision is taken as if the preci-
sion were omitted. In format strings containing the %n$ form
of a conversion specification, a field width or precision
may be indicated by the sequence *m$, where m is a decimal
integer in the range [1, NL_ARGMAX] giving the position in
the argument list (after the format argument) of an integer
argument containing the field width or precision, for exam-
ple:
printf("%1$d:%2$.*3$d:%4$.*3$d\n", hour, min, precision, sec);
The format can contain either numbered argument specifica-
tions (that is, %n$ and *m$), or unnumbered argument specif-
ications (that is, % and *), but normally not both. The only
exception to this is that %% can be mixed with the %n$ form.
The results of mixing numbered and unnumbered argument
specifications in a format string are undefined. When num-
bered argument specifications are used, specifying the Nth
argument requires that all the leading arguments, from the
first to the (N-1)th, are specified in the format string.
We're just specifying a precision as an 'argument to 'printf' - and not as a 'hard-wired' number in in the first argument to printf:
printf("%-25s", foo)
vs
printf("%-*s", max, foo) # assuming max=25