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