I'm just trying to understand why when I use a couple FIFO FDs in a paste command I get a 'Broken Pipe' but when I use Command Substitution everything is all good.

A little background: I have a need to process a rather large array, looking for particular values, and finally do a litany of tasks a user could want. Speed is pretty important with this large dataSet. What I've come up with so far is the idea of simply printing the array (subscripts and values in parallel as both subscripts and values will be used in user tasks), pasting them together so that every array item can be processed in sequence by the user in a 'stream' that'd mostly be accepted by a pipeline (the users tasks).

However, what I'm finding is that the first column for the paste command (the array subscripts) aren't making it.

Here's a very simplified example in commands (create_tmp_fifo does simply what it looks like, very simple. The 'cat' in the pipeline is just an abstract example of a user task):

fifo_pasteOutput=$(create_tmp_fifo) fifo_subscriptPrint=$(create_tmp_fifo) fifo_valuePrint=$(create_tmp_fifo);
printf '%s\n' "${!DATA_SET[@]}" >$fifo_subscriptPrint &
printf '%s\n' "${DATA_SET[@]}" >$fifo_valuePrint &
paste -d'|' <$fifo_subscriptPrint <$fifo_valuePrint | cat;
printf '\n';
rm $fifo_subscriptPrint $fifo_valuePrint $fifo_pasteOutput


[1] 117250
[2] 117251
[1]-  Broken pipe             printf '%s\n' "${!DATA_SET[@]}" > $fifo_subscriptPrint
[2]+  Done                    printf '%s\n' "${DATA_SET[@]}" > $fifo_valuePrint

Why is the first process showing a 'Broken Pipe'? If I do:

paste -d'|' <(printf '%s\n' "${!DATA_SET[@]}") <(printf '%s\n' "${DATA_SET[@]}")

Everything works as expected. From my reading of the Bash manual it's my understanding that process substitution is basically doing the same thing I'm doing with specified FIFO files. Am I misunderstanding something? I'm stumped.

Avoiding using process substitution in the paste command would be preferred as the function that prints the arrays for user consumption takes various options which format the output in many various ways, hence I'm trying to cut back on a paste command for every different variation.

Thanks in advance for any insight

1 Answer 1


I feel dumb. Already found the answer.

paste -d'|' $fifo_subscriptPrint $fifo_valuePrint

Was looking at the command one last time and wondered if the arguments it takes are just the files themselves. Anyway, thanks for anyone's time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.