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?

The essential part of this answer is to use tee. If you're certain shells like Bash, you can pipe tee's output using >(some further commands). In other shells, you'd have to give tee a filename argument (this is its standard mode of operation), and then run some further commands < thatfile, and then delete the thatfile. Or see Hari's answer below.
–
dubiousjimSep 8 '12 at 13:41

texcount foo.tex | tee unmodified |sed s/$/'\\\\'/ > modified puts modified and unmodified versions of the output in the two files. How do I print the unmodified version to the terminal? I tried tee stdout but that prints nothing...
–
SeamusJan 11 '11 at 11:49

3

You can't do that, because tee sends its input to stdout and a file. The stdout is what becomes the input to sed. You could add && cat unmodified at the end. That will dump the unmodifed output to the terminal.
–
KeithBJan 11 '11 at 13:46