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

unix-shell-programming-revised-edition-programs/timer -rw-r--r-- 556 bytes
fc214385Johan Vandegriff added other old scripts, some newer ones too 1 year, 8 months 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
29
30
#!/bin/bash
root="/home/johanv/.timer"
if [ "$#" = "1" ]
then
  if [ "$1" = "get" ]
  then
    ls -1A "$root" | sort -g
  fi
fi
timer="$root/$1"
option="$2"
now=`date +%s`
test -d "$root" || mkdir "$root"
if [ "$option" = "start" ]
then
  test -f "$timer" && exit 1
  date "+%s" > "$timer"
elif [ "$option" = "stop" ]
then
  test -f "$timer" || exit 1
  rm "$timer"
elif [ "$option" = "get" ]
then
  test -f "$timer" || exit 1
  expr `date +%s` "-" `cat "$timer"`
elif [ "$option" = "reset" ]
then
  "$0" "$1" stop || exit 1
  "$0" "$1" start || exit 1
fi