Calculating Swap percentage utilization

Hello All,

I am trying to create a script that will give me the processes that consume swap in %.

i am using the below line to get it done.

virtual=`echo "$virtual/$swp*100"|bc -l|sed -e "s/\(\.[0-9][0-9][0-9]\).*/\1/g"`

but getting the following output after running it.

.039
.110

I want the output like below.

0.039
0.110
2.233
0.112

So that using cut i will compare the threshhold of swap.

Kindly help in this.

Regards

Ankit

You could make use of printf

$ printf "%0.3f\n" ".039"
0.039
$ 

y dont you try 'sar -W'

But i m looking for processes.

Regards
Ankit