我有一个小脚本,它包含JOIN
和LSBLK
命令DF
。脚本:
lsblk -n -b --output KNAME,NAME,SIZE,MOUNTPOINT | egrep -v "fd0|ram|loop|sr0|hdc|cdrom|[SWAP]" |
while read kname name size mountpoint ; do
printf '%-5s' "$kname"
printf '%-20s' "$name"
printf '%30d' "$size"
printf '%-10s' " "
if [ "$mountpoint" != "" ] ; then
df -P --exclude={tmpfs,devtmpfs,squashfs,overlay} | sed -e /^Filesystem/d | awk '{print $6 " " $1 " " $3 " " $4 " " $5}' | grep "$mountpoint "
else
echo
fi
done
我Ubuntu
有输出:
sda sda 53687091200
sda1 └─sda1 53684994048
dm-3 └─dockerVG-rootLV 53682896896 / /dev/mapper/dockerVG-rootLV 11332388 37369740 24%
sdb sdb 2147483648000
sdb1 └─sdb1 2147482599424
dm-1 ├─hddVG-dockerLV 536866717696 /var/lib/docker /dev/mapper/hddVG-dockerLV 47321992 441454152 10%
dm-2 └─hddVG-hddLV 1610612736000 /dockerhdd /dev/mapper/hddVG-hddLV 99436560 1369032916 7%
sdc sdc 751619276800
sdc1 └─sdc1 751618228224
dm-0 └─ssdVG-ssdLV 214744170496 /dockerssd /dev/mapper/ssdVG-ssdLV 66987204 127882232 35%
我想要的是。但是CentOS 6
:
sda sda 136365211648
sda1 ├─sda1 524288000 /boot /dev/sda1 82688 379364 18%
sda2 └─sda2 135839875072
dm-0 ├─vg_rproxy-lv_root-bash: printf: (dm-0): invalid number
0 dm-2 └─vg_rproxy-lv_home-bash: printf: (dm-2): invalid number
输出LSBLK
如下CentOS 6
:
sda sda 136365211648
sda1 ├─sda1 524288000 /boot
sda2 └─sda2 135839875072
dm-0 ├─vg_rproxy-lv_root (dm-0) 53687091200 /
dm-2 └─vg_rproxy-lv_home (dm-2) 80606134272 /home
输出DF
如下CentOS 6
:
/ /dev/mapper/vg_rproxy-lv_root 5778636 43074992 12%
/boot /dev/sda1 82688 379364 18%
/home /dev/mapper/vg_rproxy-lv_home 294352 73119692 1%
为什么我的脚本无法运行CentOS 6
?你能帮助我吗?如果你有如何通过 解决此问题的示例AWK
,那就太好了。