]> git.scottworley.com Git - keystroke-timestamps/blob - fill-in.sh
Include the `fill-in` helper script here
[keystroke-timestamps] / fill-in.sh
1 #!/usr/bin/env bash
2
3 set -euo pipefail
4
5 # Add zeros to epoch-timestamped streams. For example, with interval=100:
6 #
7 # Input:
8 # 10000400 3
9 # 10000500 4
10 # 10000800 2
11 #
12 # Output:
13 # 10000400 3
14 # 10000500 4
15 # 10000600 0
16 # 10000700 0
17 # 10000800 2
18 #
19 # This is helpful for feeding such streams to gnuplot.
20
21 interval=${1:-3600}
22 zero=${2:-0}
23
24 read -r prevt rest
25 echo "$prevt $rest"
26 while read -r t rest;do
27 while (( t - prevt > interval ));do
28 prevt=$(( prevt + interval))
29 echo "$prevt $zero"
30 done
31 echo "$t $rest"
32 prevt=$t
33 done