【问题标题】:How can I get a file word count while excluding a time stamp such as [00:00:00] in unix?如何在排除 unix 中的 [00:00:00] 等时间戳的同时获取文件字数?
【发布时间】:2020-11-12 04:42:17
【问题描述】:

我有一个带有文件名的文本文件,下一行是时间戳和如下所​​示的文本。

1234.wma
[00:00:00] this is where the text I want to count is. 

我使用sed 1,1d test.txt | wc test.txt 忽略了第一行,但由于时间戳,字数统计已关闭。如何让它忽略文件中的时间戳?

感谢任何帮助。

【问题讨论】:

    标签: unix text-files word-count


    【解决方案1】:

    试试

    sed '1d;s/^\[[0-9:]*\]//g' < test.txt | wc -l
    

    您可以运行多个以;分隔的sed语句

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-26
      • 2020-01-19
      • 2016-07-30
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多