adjusting string var to fixed length

Don Bolton lugnut at sequent.UUCP
Thu Jun 6 06:08:51 AEST 1991


In article <1991Jun3.181447.12656 at mnemosyne.cs.du.edu> rchattam at isis.cs.du.edu (King Chattam) writes:
>Netters,
>  I have a shell var (length 0 to 10), which I want always to be output
>to a file as fixed length 10. I tried sed, awk etc to adjust the string
>length to 10, but did not work.
>
Awks printf("%10s%s\n",$1,"|")  Or some such syntax should put out a "|"
symbol at the 11th pos. (am not at my real desk to check syntax out)

Or you could get more involved and use length to count the characters
in your variable and a while i <= 10 print " "; ++i  the tools are there
anyhow.

>  Could someone please tell me how blanks can be appended to string vars
>to make it fixed length?
>rchattam at nyx.cs.du.edu
>Thanks



More information about the Comp.unix.shell mailing list