我正在修改我在互联网上发现的一些内容,以自定义我的pi ssh登录信息,最后我遇到了错误。
以下是我的代码:
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
let totalSpace="$(df -Bm | grep /dev/root | awk {'print $4'})"
let freeSpace="$(df -Bm | grep /dev/root | awk {'print $3'})"
TOTAL=`echo "$freeSpace Mb (Free) / $totalSpace (Total)"`
# get the load averages
read one five fifteen rest < /proc/loadavg
echo "$(tput setaf 2)
.~~. .~~. `date +"%A, %e %B %Y, %r"`
'. \ ' ' / .' `uname -srmo`$(tput setaf 1)
.~ .~~~..~.
: .~.'~'.~. : Uptime.............: ${UPTIME}
~ ( ) ( ) ~ Memory.............: ${TOTAL}
( : '~'.~.'~' : )
~ .~ ( ) ~. ~
( : '~' : )
'~ .~~~. ~'
'~'
$(tput sgr0)"
它返回这些错误,我不知道如何解决它们:
/home/pi/.bash_profile: line 8: let: totalSpace=12688M: value too great for base (error token is "12688M")
/home/pi/.bash_profile: line 9: let: freeSpace=1562M: value too great for base (error token is "1562M")
答案 0 :(得分:5)
正如您在错误消息中看到的那样,当您从{{1}中拉出列时,您会获得值M
和totalSpace
的单位(freeSpace
) }。
将这些行更改为
df
这将消除totalSpace="$(df -Bm | tr -d 'M' | grep /dev/root | awk {'print $4'})"
freeSpace="$(df -Bm | tr -d 'M' | grep /dev/root | awk {'print $3'})"
输出中的所有Ms。
也放弃所有df
。它们很古老而且不需要。