先日、Raspberry Pi で温度を測定するプログラムを書いたので温度をモニタリングしながらファイルに保存していこうと思ったら画面に何も出てこなかった。すっかり忘れてたけどバッファがあるんだった。 $ python2 temp.py | tee temp.csv 昔は grep --line-buffered みたいなの使ってた気がするけど、他にも無いのかと調べてみたらコマンドのバッファを変更できる stdbuf っていうちゃんとあった。 $ man -s 1 -k buffer dmesg (1) - print or control the kernel ring buffer stdbuf (1) - Run COMMAND, with modified buffering operations for its standard streams. $ stdbuf --help