adjusting string var to fixed length

Paul Chamberlain tif at doorstop.austin.ibm.com
Wed Jun 5 23:09:20 AEST 1991


In article <1991Jun04.144951.28414 at sco.COM> john at sco.COM (John R. MacMillan) writes:
>|  Could someone please tell me how blanks can be appended to string vars
>If the fixed length is relatively short, ...

else something like this will do it (width of 75, x's for demonstration):
	a=abc
	awk 'BEGIN {printf "x%-75sx\n", "'"$a"'"; }' /dev/null

And gives you:
xabc                                                                        x

Note that without the "-", it will do right justification.

Paul Chamberlain | I do NOT speak for IBM.          IBM VNET: PAULCC AT AUSTIN
512/838-9748     | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif



More information about the Comp.unix.shell mailing list