You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
408 B
Plaintext
16 lines
408 B
Plaintext
2 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
2 years ago
|
uptime=$(( $(date +%s) - $(date -d "$(uptime -s)" +%s)))
|
||
|
ft_minutes=$(($uptime/60))
|
||
2 years ago
|
ft_hours=$(($ft_minutes/60))
|
||
|
|
||
2 years ago
|
#echo $ft_hours $ft_minutes $ft_seconds
|
||
2 years ago
|
if [[ $ft_hours -gt 0 ]] ; then
|
||
2 years ago
|
# display with leading hours
|
||
2 years ago
|
ft_mins=$(($ft_minutes % 60)) # get remaining mins
|
||
|
printf '%dH %dM' $ft_hours $ft_mins
|
||
2 years ago
|
else
|
||
|
# display with leading minutes
|
||
2 years ago
|
printf '%dM' $ft_minutes
|
||
2 years ago
|
fi
|