1. 程式人生 > >查看根分區大小,並取出根分區使用率賦值給root_disk變量。

查看根分區大小,並取出根分區使用率賦值給root_disk變量。

dev int tmp per run tmpfs 變量 掛載點 df -h

[root@localhost ~]#cd /


[root@localhost /]# df
文件系統 1K-塊 已用 可用 已用% 掛載點
/dev/mapper/centos-root 17811456 8321620 9489836 47% /
devtmpfs 917532 0 917532 0% /dev
tmpfs 933512 0 933512 0% /dev/shm
tmpfs 933512 17512 916000 2% /run

tmpfs 933512 0 933512 0% /sys/fs/cgroup
/dev/sda1 1038336 182584 855752 18% /boot
tmpfs 186704 28 186676 1% /run/user/1000
tmpfs 186704 48 186656 1% /run/user/0
/dev/sr0 4414592 4414592 0 100% /mnt


[root@localhost /]# df -h|awk ‘NR==2{print $5}‘

47%


[root@localhost /]# root_disk=$(df -h|awk ‘NR==2{print $5}‘)


[root@localhost /]# echo $root_disk
47%

查看根分區大小,並取出根分區使用率賦值給root_disk變量。