adjusting string var to fixed length

Leslie Mikesell les at chinet.chi.il.us
Fri Jun 14 05:57:23 AEST 1991


>Mark> If you are using "ksh" [...]

I've done this in /bin/sh to get fixed width numbers:

case $VAR in
  ???) VAR=0$VAR
  ;;
  ??)  VAR=00$VAR
  ;;
  ?)   VAR=000$VAR
  ;;
esac

It seems faster than calling up sed or awk, at least for small widths.

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.shell mailing list