How To Make Decimal Point Fall On The 15th Character On The Screen

If i have a variable which is a decimal number, i.e 34.05 How can you make decimal point fall on the 15th character on the screen? Or any other that you can specify? Can you do it using sed or awk?

It would help if you would say what shell you're using. With ksh...

$ x=24.15
$ typeset -R14 x1=${x%.*}
$ x="$x1${x##+([!.])}"
$ echo "123456789012345" ; echo "$x"
123456789012345
            24.15
$

I am using bash shell, thanks for reply, but what i wanna do is have something like this

  1.             40  \(where 40 is on 15th character of the screen\)

hmm, you want a script that gets a number and transforms this number in a way that you get: fourteen characters (missing digits filled by leading blanks), then a decimal point, then any number of digits that would come after the comma. Is that correct?

If so:
you could format your output with printf, using the "%f" clause. The following would display the decimal point on the fifteenth column (25-10), but fills up the last 6 digits after the comma with zeroes:

printf "%25.10f\n" 1234.5678

You can: count the number of digits after the comma and use shell variables to fill into the printf format. In our example:

typeset -i after=4
typeset -i before=0

(( before = 15 + after ))

printf "%${before}.${after}f\n" 1234.5678

Hope this helps.

bakunin