1

I wanted the output of thinkfan -n output with a timestamp next to it so I can later analyse the patterns, and found this question: Prepending a timestamp to each line of output from a command, which had a seemingly good answer to this problem, namely using:

thinkfan -n | ts

Except it doesn't work. ts works fine with all other programs I tried, just not with thinkfan. Why doesn't it work with thinkfan? Is there some way to get this to work?

fifaltra
  • 605
  • 1
  • 9
  • 20

1 Answers1

2

There are two output streams from a program—standard output and standard error. | redirects standard output, leaving standard error going straight to your terminal.

You can redirect both:

thinkfan -n 2>&1 | ts    # should work everywhere
thinkfan -n |& ts        # newer versions of bash, maybe other shells
derobert
  • 107,579
  • 20
  • 231
  • 279