uptime: rewrite in awk
This commit is contained in:
parent
d5a81af7be
commit
ec8ad3ab84
1 changed files with 13 additions and 8 deletions
|
@ -1,8 +1,13 @@
|
||||||
#!/bin/rc
|
#!/bin/awk -f
|
||||||
clock=`{cat /dev/time}
|
|
||||||
xx=`{{echo $clock(3) / $clock(4); echo '_/86400'}|hoc|sed 's/^\./0./g;s/\..*//g'}
|
BEGIN{
|
||||||
sec=$xx(1)
|
getline sysname < "/dev/sysname";
|
||||||
days=$xx(2)
|
|
||||||
cat /dev/sysname
|
getline < "/dev/time";
|
||||||
echo -n ' up '$days' days, '
|
sec = sprintf("%d", $3/$4);
|
||||||
timezone='MDT -21600' date $sec |awk '{print $4}'
|
|
||||||
|
ct = sprintf("%02d:%02d:%02d", sec%86400/3600, sec%86400%3600/60, sec%60);
|
||||||
|
printf("%s up %d days, %s\n", sysname, sec/86400, ct);
|
||||||
|
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue