发现磁盘的shell

#!/bin/bash
#set -x
diskarray=(`cat /proc/diskstats |grep -E "\bsd[a-z]\b|\bxvd[a-z]\b|\bvd[a-z]\b"|awk '{print $3}'|sort|uniq 2>/dev/null`) length=${#diskarray[@]} ##diskarray[@] --->数组diskcarray的个数
printf "{\n"
printf '\t'"\"data\":["
for ((i=0;i<$length;i++))
do
printf '\n\t\t{'
printf "\"{#DISK_NAME}\":\"${diskarray[$i]}\"}"
if [ $i -lt $[$length-1] ];then
printf ','
fi
done
printf "\n\t]\n"
printf "}\n"
上一篇:android,view的执行过程onDraw、onSizeChanged,onFinishInflate


下一篇:html_02之表单、其它