shell - How do I get the percentage of used storage in the UNIX server -


i want percentage of disk space in unix server

filesystem      size  used avail use% mounted on /dev/sda1       457g   90g  344g  21% / udev            2.0g  4.0k  2.0g   1% /dev tmpfs           798m  1.1m  797m   1% /run none            5.0m     0  5.0m   0% /run/lock none            2.0g   23m  2.0g   2% /run/shm cgroup          2.0g     0  2.0g   0% /sys/fs/cgroup 

i using following command percentage data

df -h > space.txt  space=`head -2 space.txt | tail -1 | cut -d' ' -f15 | sed 's/%.*$//'` 

is there command "used percentage" directly

you use this:

used=$(df / | awk 'end{print $5}') echo $used 56% 

rather running df without specifying filesystem mean , looking in mass of lines, specify / filesystem front, know result on last line. take advantage of using end in awk 5th field in last line only.


Comments

Popular posts from this blog

google app engine - 403 Forbidden POST - Flask WTForms -

Android layout hidden on keyboard show -

Parse xml element into list in Python -