[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] [已解决]批处理如何判断txt最后10行是否包含某些字符串并输出这些行?

判断一较大文件 123.txt的最后10行:如果含有字符串“错误” 和“AutoConfig”,则把该文件复制到指定位置d:\456.txt;
提取456.txt的倒数第4行的前6个字符,并输出最后20行中包含该6个字符串的所有行到一个文件d:\789.txt
批处理能快速做到这些吗?请大家帮忙,谢谢!

123.txt的内容
信息 2018/6/30 22:13:09 Microsoft-Windows-Kernel-General 1 无
信息 2018/6/30 22:11:10 Microsoft-Windows-Kernel-General 1 无
信息 2018/6/30 22:07:57 Service Control Manager
信息 2018/6/30 22:03:10 Service Control Manager
信息 2018/6/30 22:03:10 Service Control Manager
错误 2018/6/30 22:03:10 Service Control Manager
错误 2018/6/30 22:03:10 Service Control Manager
信息 2018/6/30 22:03:09 Microsoft-Windows-Kernel-General 1 无
信息 2018/6/30 22:03:07 Service Control Manager
信息 2018/6/30 22:03:05 Service Control Manager
信息 2018/6/30 22:03:05 Microsoft-Windows-WLAN-AutoConfig 4000 无
信息 2018/6/30 22:03:05 Service Control Manager
错误 2018/6/30 22:03:05 Service Control Manager
信息 2018/6/30 7:08:02 Service Control Manager
信息 2018/6/30 7:08:02 Service Control Manager
信息 2018/6/30 7:08:00 Microsoft-Windows-Winlogon 7001 -1101
信息 2018/6/30 7:08:00 Service Control Manager
信息 2018/6/30 7:08:00 Microsoft-Windows-WLAN-AutoConfig 4000 无
信息 2018/6/30 7:08:00 Service Control Manager
信息 2018/6/30 7:08:00 Microsoft-Windows-DHCPv6-Client 51046 服务状态事件
错误 2018/6/30 7:08:00 Service Control Manager
信息 2018/6/30 7:08:00 Microsoft-Windows-Dhcp-Client 50036 服务状态事件
信息 2018/6/30 7:08:00 Service Control Manager
信息 2018/6/30 7:08:00 Service Control Manager
1

评分人数

    • Batcher: 感谢给帖子标题标注[已解决]字样PB + 2

回复 3# cfwyy77_bat


    谢谢回复,已经解决!

TOP

返回列表