windows - 批量删除旧行
问题描述
我有一个 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
解决方案
对不起我的能力,我正在努力
powershell.exe -Command get-content "D:\filelog.txt" | where { [datetime]($_.split(','))[0] -ge (get-date).date.adddays(-30)}
set-content "D:\Newfilelog.txt"
显然我错了,因为它不起作用
推荐阅读
- html - 在 Swift 中为 PDFKit 在 html 中添加分页符
- php - Laravel 使用 whereHas 查询
- php - symfony 5 获取路由ID
- prolog - Prolog 中的这个程序是做什么的?
- reactjs - 单spa环境下如何在.test.js文件中导入其他应用导出的文件
- c++ - C++20 P0784R7 与 P1004R2 constexpr std::vector 相比,非瞬态分配太脆弱
- javascript - 如何在 javascript fullCalendar 中添加事件
- python - InvalidSchema 没有连接适配器 Python 请求
- grpc - gRPC 的 Trailer 与通常的标头有何不同
- javascript - 如何使用机器人在 Discord 上创建“仅限媒体”频道?(JS)