I am looking for a portable bash solution for a simple FIFO stackqueue. My stackqueue input will always be a single line of text.I came up with a simple solution, which works well.
fifo_stack="fifofifo_queue="fifo.txt";
fifo_tmp="fifo.tmp"
# put a new line into FIFO
echo "append to FIFO a line" >> $fifo_stack;
#get line back from FIFO
echo $(head -n1 "$fifo_stack""$fifo_queue")
tail -n +2 "$fifo_stack""$fifo_queue" > "$fifo_tmp" && mv "$fifo_tmp" "$fifo_stack""$fifo_queue"
Now the question: Is there a more elegant (i.e. easy understandable) way to retrieve the FIFO line. For example with a simple one-liner instead of two lines?