KnorxThieus
KnorxThieus

Reputation: 585

How can I have tee to wait for all processes?

Given the following example:

$ echo foo | tee >(grep -o oo); echo bar
foo
bar
oo

As you can see, echo bar is called before grep -o oo has terminated.

(How) is it possible to achieve the following output instead?

foo
oo
bar

Thanks in advance!

Upvotes: 0

Views: 249

Answers (1)

Barmar
Barmar

Reputation: 781058

The problem is that the process substitution runs that command in the background.

Put the second echo inside the process substitution.

echo foo | tee >(grep -o oo; echo bar)

Upvotes: 1

Related Questions