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?

  • Does thinkfan -n 2>&1 | ts work? (or thinkfan -n |& ts if you've got a new-enough bash) – derobert Jan 29 '14 at 17:52
  • @derobert yes, it does... stupid me :D should have thought of that. – fifaltra Jan 29 '14 at 17:55
  • I'll add an answer, then... At least it'll leave a Google artifact for the next person who's having an "is it plugged in?" day. – derobert Jan 29 '14 at 17:58
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.