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語句外,它似乎都能正常工作。但我無法弄清楚它有什麼問題。任何建議或協助?
提前謝謝:)
的可能重複【如何聲明和在shell腳本中使用布爾變量?](http://stackoverflow.com/questions/ 2953646/how-to-declare-and-use-boolean-variables-in-shell-script) – BroSlow