add helper to reassemble chunks

This commit is contained in:
frederik
2024-11-23 19:26:35 +01:00
committed by Nachtzuster
parent 1dd6fe7f14
commit 50b31d9acb
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# read from pipe a set number of times
usage() { echo "Usage: $0 -n <chunks> -f <pipe>" 1>&2; exit 1; }
unset -v ACTION
unset -v ARCHIVE
unset -v QUIET
while getopts "n:f:" o; do
case "${o}" in
n)
COUNT=${OPTARG}
;;
f)
PIPE=${OPTARG}
;;
*)
usage
;;
esac
done
[ -z "$COUNT" ] && usage && exit 1
[ -z "$PIPE" ] && usage && exit 1
! [ -p $PIPE ] && echo "Not a pipe" && exit 1
while [ $COUNT -gt 0 ]
do
cat $PIPE
COUNT=$(( $COUNT - 1 ))
done