I have very complicated set of commands:
command | ... | ... | tee >(grep -c '[^3]$') >(grep -c '[^35]$') 1>/dev/null
I don't want to have a temporary file to save up output, as it is pretty huge. I tried doing >(grep -c '[^3]$' | read variable)
and >(grep -c '[^3]$' | read variable2)
but I guess bit doesn't work because of process substitution's sub-shell invocation.
What can I do to pipe output directly to multiple variables? Is it even possible?
Right now I have this workaround:
var=$(command ... | ... | ... | tee >(grep -c '[^3]$') >(grep -c '[^35]$') 1>/dev/null)
var1=$(tail -1 <<< $var)
var2=$(head -1 <<< $var)
but I think it is clumsy and doesn't look nice. I am aware I can grep into another file but I don't like it either.
Thanks in advance.