#!/bin/bash # (0) Get current ABS directory ROOT=$(dirname `realpath $0`); # (1) Check arguments test $# -lt 1 && echo "ERR: Missing arguments (id)" && exit 1; # (2) Manage optional argument # FLUSH=1; test $# -ge 2 -a "$2" = "-" && FLUSH=0; # (2) load configuration file test -f /tmp/inbuf_$1 || ( echo "ERR: No such id" && exit 1 ) || exit 1; # (3) Read content from file cat /tmp/inbuf_$1; # (4) Flush buffer test $FLUSH -eq 1 && echo -ne "" > /tmp/inbuf_$1;