Skip to main content
edited body; edited title
Source Link

bash: a simple FIFO (first-in first-out) stackqueue

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?

bash: a simple FIFO (first-in first-out) stack

I am looking for a portable bash solution for a simple FIFO stack. My stack input will always be a single line of text.I came up with a simple solution, which works well.

fifo_stack="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")
tail -n +2 "$fifo_stack" > "$fifo_tmp" && mv "$fifo_tmp" "$fifo_stack"

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?

bash: a simple FIFO (first-in first-out) queue

I am looking for a portable bash solution for a simple FIFO queue. My queue input will always be a single line of text.I came up with a simple solution, which works well.

fifo_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_queue")
tail -n +2 "$fifo_queue" > "$fifo_tmp" && mv "$fifo_tmp" "$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?

added 6 characters in body
Source Link

I am looking for a portable bash solution for a simple FIFO stack. My stack input will always be a single line of text.I came up with a simple solution, which works well.

fifo_stack="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")
tail -n +2 "$fifo_stack" > "$fifo_tmp" && mv "$fifo_tmp" "$fifo_stack"

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?

I am looking for a portable bash solution for a simple FIFO stack. My stack will always be a single line of text.I came up with a simple solution, which works well.

fifo_stack="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")
tail -n +2 "$fifo_stack" > "$fifo_tmp" && mv "$fifo_tmp" "$fifo_stack"

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?

I am looking for a portable bash solution for a simple FIFO stack. My stack input will always be a single line of text.I came up with a simple solution, which works well.

fifo_stack="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")
tail -n +2 "$fifo_stack" > "$fifo_tmp" && mv "$fifo_tmp" "$fifo_stack"

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?

Source Link

bash: a simple FIFO (first-in first-out) stack

I am looking for a portable bash solution for a simple FIFO stack. My stack will always be a single line of text.I came up with a simple solution, which works well.

fifo_stack="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")
tail -n +2 "$fifo_stack" > "$fifo_tmp" && mv "$fifo_tmp" "$fifo_stack"

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?