1

I know that in bash, the & symbol delegates a command to the background, but is it also supposed to double as a special line terminator?

To give an example of what I'm referring to, I found this line in http://tldp.org/LDP/abs/html/ioredirintro.html

while read a; do echo "FIFO1: $a"; done < /tmp/fifo1 & exec 7> /tmp/fifo1

is the above equivalent to..?

while read a; do echo "FIFO1: $a"; done < /tmp/fifo1 &
exec 7> /tmp/fifo1

Or is there special significance to these two parts being in the same line?

joelliusp
  • 113

1 Answers1

4
while read a; do echo "FIFO1: $a"; done < /tmp/fifo1 & exec 7> /tmp/fifo1

is indeed equivalent to

while read a; do echo "FIFO1: $a"; done < /tmp/fifo1 &
exec 7> /tmp/fifo1

& acts as a command separator, as well as placing the command preceding it in the background.

Strictly speaking, it acts as a separator for items in a list of commands:

A list is a sequence of one or more pipelines separated by one of the operators ‘;’, ‘&’, ‘&&’, or ‘||’, and optionally terminated by one of ‘;’, ‘&’, or a newline.

Stephen Kitt
  • 434,908