changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: uptime: rewrite in awk

changeset 7138: 512c2024f16a
parent 7137: 84d491804c1b
child 7139: fefcbee0b135
author: BurnZeZ
date: Sun, 07 Apr 2019 17:09:52 +0000
files: rc/bin/uptime
description: uptime: rewrite in awk
     1.1--- a/rc/bin/uptime
     1.2+++ b/rc/bin/uptime
     1.3@@ -1,8 +1,13 @@
     1.4-#!/bin/rc
     1.5-clock=`{cat /dev/time}
     1.6-xx=`{{echo $clock(3) / $clock(4); echo '_/86400'}|hoc|sed 's/^\./0./g;s/\..*//g'}
     1.7-sec=$xx(1)
     1.8-days=$xx(2)
     1.9-cat /dev/sysname
    1.10-echo -n ' up '$days' days, '
    1.11-timezone='MDT -21600' date $sec |awk '{print $4}'
    1.12+#!/bin/awk -f
    1.13+
    1.14+BEGIN{
    1.15+	getline sysname < "/dev/sysname";
    1.16+
    1.17+	getline < "/dev/time";
    1.18+	sec = sprintf("%d", $3/$4);
    1.19+
    1.20+	ct = sprintf("%02d:%02d:%02d", sec%86400/3600, sec%86400%3600/60, sec%60);
    1.21+	printf("%s up %d days, %s\n", sysname, sec/86400, ct);
    1.22+
    1.23+	exit
    1.24+}