Re: [flalug] pad a variable with spaces in bash?

From: Ronald KA4INM Youvan (ka4inm@tampabay.rr.com)
Date: Sun Feb 15 2004 - 10:46:39 EST


I find this problem intriguing, typeset is not in my confusor. Slackware 9.1
        From the Inet:
DESCRIPTION
       typeset sets attributes and values for shell variables and functions.
When typeset is invoked inside a function, a new instance of the variables name
is created. The variables value and type are restored when the function
completes. The following list of attributes may be specified:

-L
     Left justify and remove leading blanks from value. If n is non-zero it
defines the width of the field; otherwise, it is determined by the width of the
value of first assignment. When the variable is assigned to, it is filled on the
right with blanks or truncated, if necessary, to fit into the field. Leading
zeros are removed if the -Z flag is also set. The -R flag is turned off.

--
   The unusual spacing seems to come from typeset. (I've never used ksh) are
you sure typeset exists and you are calling it correctly?

Ron

> Does anybody know how to pad a variable with spaces in bash? In {pd}ksh,

> .-- > | #! /bin/ksh > | typeset -L8 foo=bar > | echo "a${foo}b" > '--

> would print > abar b

> How would I do a similar thing in bash (without calling ksh -c 'typeset > -L8 foo=bar; echo "a${foo}b"')? -- 73 (= Best Regards) de: Ron ka4inm@tampabay.rr.com 100% LINUX, since July, 1997 SENT Time and Date are UTC Visit my HAM Web SITE at: http://www.qsl.net/ka4inm



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:08:50 EDT