-
Notifications
You must be signed in to change notification settings - Fork 0
/
Uptime.sh
30 lines (27 loc) · 1.1 KB
/
Uptime.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
einheit=$(uptime | awk '{print $4 }' | sed 's/,//' | sed 's/s//')
subeinheit=$(uptime | awk '{print $6 }' | sed 's/,//' | sed 's/s//')
ok=false
case "$einheit" in
"ecs") ausgabe=$(uptime | awk '{print $3+0 " " $4}' | sed 's/secs,/Sekunden/');ok=true;;
"min" ) ausgabe=$(uptime | awk '{print $3+0 " " $4}' | sed 's/mins,/Minuten/' | sed 's/min,/Minute/');ok=true;;
"hr") ausgabe=$(uptime | awk '{print $3+0 " " $4}' | sed 's/hrs,/Stunden/' | sed 's/hr,/Stunde/');ok=true;;
esac
if [ "$ok" = "false" ]
then
if [ "$einheit" = "day" ] || [ "$einheit" = "days" ]
then
if [ "$subeinheit" = "ecs" ]
then
ausgabe=$(uptime | awk '{print $3 " " $4 " " $5 }' | sed 's/days,/Tage/' | sed 's/day,/Tag/')" Sekunden"
elif [ "$subeinheit" = "min" ]
then
ausgabe=$(uptime | awk '{print $3 " " $4 " " $5 }' | sed 's/days,/Tage/' | sed 's/day,/Tag/')" min"
else
ausgabe=$(uptime | awk '{print $3 " " $4 " " $5 }' | sed 's/days,/Tage/' | sed 's/day,/Tag/' | sed 's/:/h /' | sed 's/,/min/')
fi
else
ausgabe=$(uptime | awk '{print $3 }' | sed 's/:/h /' | sed 's/,/min/')
fi
fi
echo "Uptime: \t\t\t $ausgabe"