技術力をスコア化して市場価値をチェックしてみませんか?PR

ブログやSNSのアウトプットをAIが分析。技術力の順位を算出!自分の市場価値を測ってみませんか?

33
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

stdbufコマンドを使用してコマンドの標準出力にタイムスタンプを追加

Posted at

stdbufコマンドは、標準入出力ストリームのバッファ動作を変更してしてコマンドを実行することが可能。
http://linuxjm.sourceforge.jp/html/GNU_coreutils/man1/stdbuf.1.html

やりかた

command | stdbuf -oL gawk '{print strftime("[%a %b %e %H:%M:%S %Z %Y] "), $0; }'

commandの標準出力をうばって、行の先頭に時刻を追加しているだけです。

テストスクリプト

test.sh
echo "init"
sleep 1
echo "processing ..."
sleep 2
echo "done"

動作例

$ ./test.sh | stdbuf -oL gawk '{print strftime("[%a %b %e %H:%M:%S %Z %Y] "), $0; }'
[Sun Mar  9 16:04:06 UTC 2014]  init
[Sun Mar  9 16:04:07 UTC 2014]  processing ...
[Sun Mar  9 16:04:09 UTC 2014]  done
33
28
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

Qiita Advent Calendar is held!

Qiita Advent Calendar is an article posting event where you post articles by filling a calendar 🎅

Some calendars come with gifts and some gifts are drawn from all calendars 👀

Please tie the article to your calendar and let's enjoy Christmas together!

33
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?