例えばある種の値をモニタしたい場合、タイムスタンプをつけておくと便利かもしれない。
$ while [ 1 ]; do cat /proc/sys/kernel/random/entropy_avail; sleep 1; done | awk '{ print strftime("%Y/%m/%d %H:%M:%S"), $0 }' 2010/10/04 13:33:28 3532 2010/10/04 13:33:29 3532 2010/10/04 13:33:30 3532 2010/10/04 13:33:31 3532 2010/10/04 13:33:32 3532 2010/10/04 13:33:33 3532 2010/10/04 13:33:34 3532 2010/10/04 13:33:35 3532 2010/10/04 13:33:36 3532 ^C
awk: line 2: function strftime never defined と言われたら
# apt-get install gawk
awk
$ vmstat -n 1 | awk '{ print strftime("%Y/%m/%d %H:%M:%S"), $0 }' 2010/10/04 13:37:46 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- 2010/10/04 13:37:46 r b swpd free buff cache si so bi bo in cs us sy id wa st 2010/10/04 13:37:46 1 0 184352 96244 315536 309132 0 1 181 43 22 33 0 0 98 1 0 2010/10/04 13:37:47 0 0 184352 96216 315536 309132 0 0 0 0 141 154 0 0 100 0 0 2010/10/04 13:37:48 0 0 184352 96248 315536 309132 0 0 0 0 88 112 0 0 100 0 0 2010/10/04 13:37:49 0 0 184352 96248 315536 309132 0 0 0 0 86 113 0 0 100 0 0 2010/10/04 13:37:50 0 0 184352 96248 315536 309132 0 0 0 0 89 117 0 0 100 0 0 2010/10/04 13:37:51 0 0 184352 96280 315540 309128 0 0 0 4 93 131 0 0 100 0 0 2010/10/04 13:37:52 0 0 184352 96280 315540 309128 0 0 0 0 92 114 0 0 100 0 0 2010/10/04 13:37:53 0 0 184352 96312 315548 309128 0 0 0 12 104 140 0 0 100 0 0 2010/10/04 13:37:54 0 0 184352 96312 315548 309128 0 0 0 0 115 137 0 0 100 0 1 2010/10/04 13:37:55 0 0 184352 96344 315548 309128 0 0 0 0 86 112 0 0 100 0 0 ^C