编码:
first=true
mountpoint=" "
partlist=`df -h | grep "^/dev"` # get partition info
for i in $partlist # loop through info
do
if [[ ${i:0:1} = "/" ]] # items starting with / are what I'm interested in
then
if [[ $first ]] # The first instance in each pair is the device name
then
mountdev=$i
mountpoint=" "
first=false
else # The second instance is the device mount point
mountpoint=$i
first=true
fi
if [[ $mountpoint != " " ]] # If the mountpoint was just set (last to be set
# before printing config)
then
# Print config
echo "${mountpoint} \${fs_size ${mountpoint}"
echo "USED \${fs_used ${mountpoint}}\${alignr}\${fs_free ${mountpoint}} FREE"
echo "\${fs_bar 3,300 ${mountpoint}}"
echo "READ \${diskio_read ${mountdev}}\${alignr}\${diskio_write ${mountdev}} WRITE"
echo ""
fi
fi
done
问题:
目标是创建一个脚本,该脚本将为我的每台计算机生成我喜欢的 conky 配置,而无需为每台计算机编辑文件。以上是一个片段,它生成报告我的磁盘使用信息的部分。不幸的是,我无法让它输出任何东西。我向其中抛出了各种调试回声,除了实际输出配置的 if 语句外,它似乎都正常工作。我无法弄清楚它有什么问题。有什么建议或帮助吗?
提前谢谢你:)