코드 :배쉬 블록이 실행되지 않을 경우 때 명확하게해야
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 문을 제외한 모든 것이 올바르게 작동하는 것처럼 보입니다. 나는 그것이 무엇이 잘못되었는지 알아낼 수 없다. 어떤 제안이나 도움이 필요합니까?
사전 감사합니다 :)
가능한 중복 [선언하고 쉘 스크립트에서 부울 변수를 사용하는 방법?] (http://stackoverflow.com/questions/ 2953646/how-to-declare-and-use-boolean-variables-in-shell-script) – BroSlow