Help Debugging Kshell Script???

horio shoichi bugsgrief at bugsgrief.net
Sun Aug 8 15:20:28 PDT 2004


On Sun, 08 Aug 2004 11:37:01 -0400
"Hakim Z. Singhji" <hakim.singhji at earthlink.net> wrote:

> do
> # Use the bc utility in a here document to calculate the percentage of
> # free and used swap space
> 
> PERCENT_USED=$(bc <<EOF
> scale=4
> ($SW_USED / $SW_TOTAL) * 100
> EOF
> )
> 
> PERCENT_FREE=$(bc <<EOF
> scale=4
> ($SW_FREE / $SW_TOTAL) * 100
> EOF
> )
> ##########################################################################

Which ksh are you running (/usr/local/bin/ksh{,93)) ?

If you are really new to this sort of things, test them interactively
with 'set -ux' options.


horio shoichi

BTW., it gave me a thing like this on 4.9-STABLE with /usr/local/bin/ksh.


% ksh
$ SW_USED=1
$ SW_TOTAL=3
$ PERCENT_USED=$(bc <<EOF
> scale=4
> ($SW_USED / $SW_TOTAL) * 100
> EOF
> )
$ echo $PERCENT_USED
33.3300
$ ^D
%



More information about the freebsd-questions mailing list