LoginSignup
3
5

More than 5 years have passed since last update.

grep, nkfコマンドでバッファしないようにする

Posted at

tail -f のあとに grep や nkf をつけること結構あると思います:relaxed:

その際、grepもnkfも結果をある程度バッファにため込んでから出力するので
リアルタイムに確認することができずにちょっぴり困ってました。

でも、あるんですね、ちゃんと考慮されたオプションが:heart_eyes:

grepは「--line-buffered」

tail -f test.log | grep --line-buffered

nkfは「-u」

tail -f test.log | nkf -u

これで一行ずつはき出してくれるようになるので、リアルタイムに確認出来ます。
なお、パフォーマンスが落ちると思われますので場合によっては注意が必要です

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5