~johanvandegriff/unix-shell-programming-revised-edition-programs

unix-shell-programming-revised-edition-programs/time/time3 -rw-r--r-- 627 bytes
fc214385Johan Vandegriff added other old scripts, some newer ones too 2 years ago
                                                                                
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
#!/bin/sh
hours=`date | cut -c12-13`
minutes=`date | cut -c15-16`
seconds=`date | cut -c18-20`

while true
do
  echo "$hours:$minutes:$seconds"
  sleep 0.99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
  seconds=`expr $seconds + 1`
  seconds=`printf "%02d" $seconds`
  if [ $seconds = 60 ]
  then
    seconds=00
    minutes=`expr $minutes + 1`
    minutes=`printf "%02d" $minutes`
    if [ $minutes = 60 ]
    then
      minutes=00
      hours=`expr $hours + 1`
      hours=`printf "%02d" $hours`
      if [ $hours = 25 ]
      then
        hours=01
      fi
    fi
  fi
done