This is a general shell question, but since Ive subscribed to this forum I may just ask here.. I hope you don't mind.
Im trying to grab a 2 line output by piping it to two read commands like this:
echo -e "1\n2"|(read l1;read l2)
Now, the l1 and l2 variable doesnt survive the end bracket (sub shell?). What's the easiest way to capture these and pass it to the main shell?
tests:
echo -e "1\n2"|(read l1;read l2;echo -e "$l1\n$l2");#works
echo -e "1\n2"|(read l1;read l2);echo -e "$l1\n$l2";#works not