【问题标题】:Is there any way to count added line in a file per second in CentOS?有没有办法在 CentOS 中计算每秒文件中添加的行数?
【发布时间】:2020-08-31 09:38:19
【问题描述】:

我有一个文件,当服务器从另一台服务器接收数据时会自动填写。

如何计算每秒添加到该文件的行数?

【问题讨论】:

    标签: linux file count centos


    【解决方案1】:

    我认为是的,在伪代码中:

    var lastNbLines = 0
    do :
       var currentNbLines = cat file | wc -l # this is the correct command
       var diff = currentNbLines - lastNbLines
       echo diff #delta
       lastNbLines = currentNbLines
       sleep 1000 #in ms
    While (true) // or other condition...
    

    用 bash 翻译这个? :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-09
      • 2023-03-21
      • 1970-01-01
      • 2012-12-10
      相关资源
      最近更新 更多