I need to write a script to show the Total Swap Size, Used Swap Size and % used.
Below are the commands, I'm using.
pgsize=`swapon | tail -1 | awk '{print $3}'` pgused=`swapon | tail -1 | awk '{print $4}'` pgpercent=$(($pgused * 100/ $pgsize)) The output of the commands are pgsize = 16G pgused = 22M pgpercent - I'm getting the below error in this line
22M: value too great for base (error token is "22M")
Here, how do I need to convert the 22M into 22 and 16G into 16*1024 and divide it. For eg. (22*100)/(16*1024)