Shell Text Processing – Doing Two Things with Output from a Command

shelltext processingUtilities

I have a program texcount that outputs the number of words in my LaTeX document. I can also pipe the output of this to sed to make the newlines TeX linebreaks and write this to a file which I can then include in my final document. But when I do texcount foo.tex | sed s/$/'\\\\'/ > wc.tex the command line output of texcount is suppressed.

How can I get the output of the first command to be displayed in the terminal and piped to sed?

Best Answer

You can use a anonymous pipe for the second command:

texcount foo.tex | tee >(sed s/$/'\\\\'/ > wc.tex)
Related Question