3
# uptime: condensed uptime of the machine
4
# Copyright (C) 2009 Raphaël Pinson.
5
# Copyright (C) 2009 Canonical Ltd.
7
# Authors: Raphaël Pinson <raphink@ubuntu.com>
8
# Dustin Kirkland <kirkland@canonical.com>
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, version 3 of the License.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
color 2>/dev/null || color() { true; }
26
if [ "$1" = "--detail" ]; then
31
u=$(sed "s/\..*$//" /proc/uptime)
33
if [ "$u" -gt 86400 ]; then
34
echo "$u" | awk '{printf "%dd%dh", $1 / 86400, ($1 % 86400)/3600 }'
35
elif [ "$u" -gt 3600 ]; then
36
echo "$u" | awk '{printf "%dh%dm", $1 / 3600, ($1 % 3600 )/60}'
37
elif [ "$u" -gt 60 ]; then
38
echo "$u" | awk '{printf "%dm", $1 / 60 }'