關於觀看資料的技巧 - Linux
By Ingrid
at 2009-11-10T20:27
at 2009-11-10T20:27
Table of Contents
※ 引述《DRLai (蘇打)》之銘言:
: 我寫了一些程式
: 他會在畫面上秀出數據
: (一直洗畫面的那種,因為數據不斷在變化)
: 然而我不想一次看這麼多,只需要看最新的數據而已
: 所以我的作法是
: ./xxx(執行程式) > tmp
: watch tail tmp (讓畫面只顯示最後幾行)
: 不過這樣有個壞處
: 因為資料很多,導致tmp會越來越肥
: 想請問有什麼比較好得辦法
: 能讓他保持最新的資訊卻不要一直寫到硬碟內呢?
: 感謝:D
有一個挺另類的解法, 此效果類似 wget 在下載時, 在文字介面
描繪的 progress bar. 這種 progress bar 的最後面, 都會固定
顯示變動的百分比. 而且並不需要 print escape code, 也不必
使用 curses. sample code 如下:
#include <stdio.h>
#include <unistd.h>
int main()
{
int i;
for (i = 0; i <= 100; i++) {
printf("\r%6d", i);
fflush(stdout);
usleep(100000);
}
return 0;
}
--
: 我寫了一些程式
: 他會在畫面上秀出數據
: (一直洗畫面的那種,因為數據不斷在變化)
: 然而我不想一次看這麼多,只需要看最新的數據而已
: 所以我的作法是
: ./xxx(執行程式) > tmp
: watch tail tmp (讓畫面只顯示最後幾行)
: 不過這樣有個壞處
: 因為資料很多,導致tmp會越來越肥
: 想請問有什麼比較好得辦法
: 能讓他保持最新的資訊卻不要一直寫到硬碟內呢?
: 感謝:D
有一個挺另類的解法, 此效果類似 wget 在下載時, 在文字介面
描繪的 progress bar. 這種 progress bar 的最後面, 都會固定
顯示變動的百分比. 而且並不需要 print escape code, 也不必
使用 curses. sample code 如下:
#include <stdio.h>
#include <unistd.h>
int main()
{
int i;
for (i = 0; i <= 100; i++) {
printf("\r%6d", i);
fflush(stdout);
usleep(100000);
}
return 0;
}
--
Tags:
Linux
All Comments
By Catherine
at 2009-11-14T13:34
at 2009-11-14T13:34
Related Posts
ubuntu 的氣泡通知
By Thomas
at 2009-11-10T11:05
at 2009-11-10T11:05
關於觀看資料的技巧
By Dora
at 2009-11-10T10:44
at 2009-11-10T10:44
Windows 下如何寫 makefile?
By Mia
at 2009-11-10T10:12
at 2009-11-10T10:12
problem after the ubuntu 9.10 upgrade
By Heather
at 2009-11-10T06:21
at 2009-11-10T06:21
ls和ROOT 一起被我刪掉了 請問還有救嗎
By Olive
at 2009-11-10T00:40
at 2009-11-10T00:40