首页 > 解决方案 > 批量删除旧行

问题描述

我有一个 txt 文件,其中包含一系列这样的数据

   Date      Time          Id    Set
2020/05/04 15:22:28      10005   4512
2020/05/04 15:23:47      10005   4528
2020/05/04 15:23:48      10005   4543
2020/05/04 15:23:58      10005   4555
2020/05/04 15:24:00      10005   4533
2020/05/04 15:24:03      10005   4512
2020/05/04 15:24:05      10005   4590

我需要根据写入时间删除最旧的行,我怎样才能在 txt 文件中得到这个最终结果?

2020/05/04 15:24:05      10005   4590

标签: windowsbatch-file

解决方案


对不起我的能力,我正在努力

    powershell.exe -Command get-content "D:\filelog.txt" | where { [datetime]($_.split(','))[0] -ge (get-date).date.adddays(-30)} 
set-content "D:\Newfilelog.txt"

显然我错了,因为它不起作用


推荐阅读