On 09/05/2013 12:44 PM, Bauer, Bobby (NIH/CIT) [E] wrote: > I've spent a nice part of the day trying to figure out how to pad a variable > with leading zeroes and still keep the decimal. The variable needs to be > formatted nnnnn.nn. Printf with a %d clobbers the decimal. Any suggestions > not using SED or AWK?
Are you using the 'printf' built into BASH or the one from the COREUTILS package? If the latter, then it's external to the shell and has the same overhead as 'sed' or 'awk'. There are other variable handling tricks built into BASH. I don't know it well enough to say how to pad. (Makes me start thinking I'm in DEC VMS "DCL" again, which is fine except for how it rips the fabric of time and space.) But there may be a better way using built-ins than 'printf'. Need a BASH guide to say more. I urge you to try with 'awk' (and don't get hooked on BASH-isms) because using more common tools lets your scripts run on non-Linux systems (OpenVM, OSX, AIX, Solaris, others). ---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390 ---------------------------------------------------------------------- For more information on Linux on System z, visit http://wiki.linuxvm.org/
