Given a command the output of which is being processed by, for example, grep I also want the actual output to be included in the log file for debugging purposes.For example if I have the followinguseful=$(curl -s http://example.com/some/data | grep 'useful line')echo useful=$usefulI want to seeThis page has a number of lines in it, but'useful lines are the only ones I care aboutexcept when something goes wrong and thenI'd really like to see what the heck was inthe output that grep consumed.useful=useful lines are the only ones I care aboutThis can be done with tee like souseful=$(curl -s http://example.com/some/data | tee /proc/$$/fd/1 | grep 'useful line')echo useful=$usefulbut if stdout is being redirected to a file tee clobbers the rest of your log file. tee -a fails in largely the same way.
copy consumed output to stdout when stdout is redirected to a file
bash;io