I don't know if this is possible. Still fairly new to ksh scripting. Here is what I am wanting to do with my output.
change the following
From:
1349870987
To:
1,349,870,987
in my output. How do I do this?
Thanks,
S
I don't know if this is possible. Still fairly new to ksh scripting. Here is what I am wanting to do with my output.
change the following
From:
1349870987
To:
1,349,870,987
in my output. How do I do this?
Thanks,
S
#! /usr/bin/ksh
i1=1349870987
echo $i1
typeset -Z12 i2=$i1
echo $i2
i3=$(echo $i2 | sed 's/\(...\)/,\1/g')
echo $i3
i4=${i3##+([0,])}
echo $i4
exit 0
i1 is the original number.
i2 has been formatted to have leading zeros. The 12 was arbitrary, but it must be larger than the number of digits in the number and it must be a multiple of 3.
i3 results by using sed to prepend a comma to every 3 digits in the number.
i4 is the final result where we have removed leading commas and zeroes.