test(unitproc):bkFreqWrite: Implem. basic mapfile reading
[BK-2020-03.git] / unitproc / bkFreqWrite
1 #!/bin/bash
2 # Desc: Writes stdin to disk every 5 minutes
3
4 yell() { echo "[$(date --iso-8601=ns)]:$0: $*" >&2; } #o Yell, Die, Try Three-Fingered Claw technique
5 die() { yell "$*"; exit 111; } #o Ref/Attrib: https://stackoverflow.com/a/25515370
6 try() { "$@" || die "cannot $*"; } #o
7
8 declare -a buffer
9
10 yell "Script started."
11
12 mapfile -s4 -n5 buffer
13
14 yell "Contents of buffer:${buffer[@]}";
15
16 for element in "${buffer[@]}"; do
17 echo "$element";
18 sleep 1;
19 done;
20
21 yell "Script completed."
22 exit 0;