在很多shell命令中輸出的是連續的事件流,比如系統日誌。我只需要查看現在或當前系統時間的輸出。 這裏是一個程序的輸出,我從亞行logcat獲得,如何從當前時間戳獲取shell輸出。 Linux,unix
09-03 17:12:04.562 479 957 I ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.amazon.mShop.android/com.amazon.mShop.home.HomeActivity } from pid 1230
09-03 17:12:04.687 479 1030 I ActivityManager: Start proc com.amazon.mShop.android for activity com.amazon.mShop.android/com.amazon.mShop.home.HomeActivity: pid=19164 uid=10158 gids={1006, 3003}
09-03 17:12:05.593 479 912 I ActivityManager: Starting: Intent { dat=?paramSuggestionText=cell%20phone flg=0x20000 cmp=com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity (has extras) } from pid 19164
09-03 17:12:05.796 479 620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity: +186ms (total +1s119ms)
09-03 17:12:08.601 479 620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.home.HomeActivity: +3s925ms
09-03 17:12:08.601 479 620 I ActivityManager: Resumed Activity: com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity totalTime: 4037 ms
09-03 17:13:35.742 479 957 I ActivityManager: Starting: Intent { act=intentActionStartActivity flg=0x20000 cmp=com.amazon.mShop.android/com.amazon.mShop.categoryBrowse.CategoryBrowseActivity } from pid 19164
09-03 17:13:36.007 479 620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.categoryBrowse.CategoryBrowseActivity: +222ms
09-03 17:13:53.328 479 957 I ActivityManager: Starting: Intent { dat=?¶mSuggestionFilters=s%3An%3A%2C%3A4991425011%0As%3An%3A%2C%3A4991426011%0As%3An%3A%2C%3A5088769011%0As%3An%3A%2C%3A5263615011¶mDepartmentName=Programs flg=0x20000 cmp=com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity (has extras) } from pid 19164
09-03 17:13:53.484 479 620 I ActivityManager: Displayed com.amazon.mShop.android/com.amazon.mShop.search.SearchActivity: +145ms
這是一個連續的數據流,這是從系統啓動的事件,但我只需要一個從當前系統時間的日誌。那麼,我該如何實現呢?
你是什麼意思「從當前系統時間」?這是否意味着一個範圍,從某個(「當前」)時間開始,永不結束?你如何定義「當前」時間?什麼時候執行某種命令? – GreyCat
@GreyCat我的意思是隻需要發出命令的輸出。但一些命令,如android adb logcat顯示系統啓動的所有日誌,我不需要,我只需要從我在終端發出命令的時間開始的日誌。 –