Unix /Linux 用行号显示文件的最后一部分

Erw*_*win 5 linux unix command-line tail

有没有办法让tail在它显示的最后几行前面显示一个行号,以便在脚本中使用它时显示文件的增长。

例如:在这样的脚本中使用它时:

while [-z $(ps -p $pid) ]; do
   echo  "process is running"
   .....
   tail process.logfile
   sleep 15
   clear
done
Run Code Online (Sandbox Code Playgroud)

输出应该是:

111线 111
112线 112
113线 113
114线 114
115线 115
....

下一轮应该是:
116 line 116
117 line 117
118 line 118
119 line 119
120 line 120
...

jdh*_*jdh 5

tail 本身没有行编号功能,但其他实用程序有。这是一个典型的解决方案:

cat -n process.logfile | 尾巴