Tail

使less的跟隨選項顯示線移動

  • May 15, 2013

我經常發現自己使用 less 來顯示包含數百個連續的、相同的行的日誌文件,這些行以設定的時間間隔附加到文件中。

例如,

something happened
something happened
something happened
something happened
something happened
something happened
something happened
... (100 identical lines later)
something happened
something happened

我使用 less 的 follow 選項來跟踪日誌文件,但是一旦列印了一定數量的相同行,就無法判斷日誌文件是否仍在寫入。

tail與標誌一起使用-f通過允許我在其輸出中放入換行符來解決這個問題,它與文本一起浮動,顯示文本的流動/運動。

$ tail -f a-terrible-log-file   |   (a few seconds later)
something happened              |   something happened      
something happened              |   something happened      
something happened              |   something happened      
something happened              |   something happened      
something happened              |   
something happened              |   something happened      
something happened              |   something happened      
something happened              |   something happened      
something happened              |   something happened      
something happened              |   something happened      
something happened<C-j>         |   something happened
                               |   something happened                        
something happened              |   something happened      
something happened              |   something happened      
something happened              |   something happened      
something happened              |   something happened      

有沒有辦法顯示線流/移動less

你可以從-N顯示行號開始。

引用自:https://unix.stackexchange.com/questions/75869