如何连续显示文件的最后几行内容 [英] how to continuously display a file of its last several lines of contents
问题描述
我试图找到一个Unix命令(也许是组合命令),该命令如何连续显示最后几行内容的文件.但是,在此显示期间,我希望当滚动内容到达屏幕顶部时,某些最上面的行始终显示在屏幕顶部.
I am trying to find a Unix command (combination, maybe) on how to continuously display a file of its last several lines of contents. But during this displaying, I want some of the top lines are always displayed on the screen top when the rolling contents reach the screen top.
有可能吗?
(1)假设我有文件"job.sta",前两行是: 职位名称,约翰在2013年1月30日的职位,... Tab1,Tab2,Tab3 0、1、2 1、90、89 2,89,23 ...
(1) Suppose I have file, "job.sta", the first 2 lines are: job name, John's job on 2013-Jan-30,... Tab1, Tab2, Tab3 0, 1, 2, 1, 90, 89 2, 89, 23 ...
(2)该文件正在运行中,其内容正在增长,并且我不知道它将以哪行结尾.
(2) This file is on its running, its contents are growing, and I don't know what line it's going to end.
(3)因此,当更新内容到达Unix Shell屏幕顶部时,我想在使用tail命令时显示(始终)前两行.我目前正在使用PuTTY.
(3) So I want to display (always) the first 2 lines when using tail command, when the updating contents reaches a Unix shell screen top. I am using PuTTY at the moment.
参考: http://www .unix.com/unix-dummies-questions-answers/172000-head-tail-how-display-middle-lines.html
推荐答案
这将每2秒更新一次,而不是每当将数据写入文件时更新一次,但这也许就足够了:
This will update every 2 seconds rather than whenever data is written to the file, but perhaps that's adequate:
watch 'head -n 2 job.sta; tail job.sta'
这篇关于如何连续显示文件的最后几行内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!