X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=c%2Fgoertzel%2Fsleepcount.sh;h=920e42b0d86cc4f62018c3d8595bb8e54b476407;hb=991ef83fab62bdf4e2d7c3dda4bb21352143f8ed;hp=dbfda3e5665be612749348049aafc78099519463;hpb=3e5828b5bfdae6ef1457d8e44c551369e12e467b;p=mirrors%2FPrograms.git diff --git a/c/goertzel/sleepcount.sh b/c/goertzel/sleepcount.sh index dbfda3e..920e42b 100755 --- a/c/goertzel/sleepcount.sh +++ b/c/goertzel/sleepcount.sh @@ -1,9 +1,11 @@ #!/bin/bash -seconds=$2 +seconds="$2" START=$(head -n 1 "$1" | cut -f 2) -STARTOK=$(tail -n 1 "$1.counts.$seconds" | cut -f 1) +STARTOK=$({ tail -n 1 "$1.counts.$seconds" || echo 0; } | cut -f 1) STOP=$( tail -n 1 "$1" | cut -f 2) +fuser "$1.counts.$seconds" &>/dev/null && exit 23; + test "$STARTOK" -gt "$START" && START="$STARTOK"; seq $START $STOP | while read MAX; do MIN=$(( $MAX - $seconds ))