[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
type xxx.txt | findstr /r /i /c:"^ab cd.*N OP$"

TOP

回复 3# 踏沙行


    当然试过,而且经常用
Microsoft Windows [版本 10.0.17134.167]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\WHY>type E:\test\a.txt
ab cd efgh N OL
ab ce efgh N OP
ab cd efgh N OP
C:\Users\WHY>type E:\test\a.txt | findstr /r /i /c:"^ab cd.*N OP$"
ab cd efgh N OP

C:\Users\WHY>

TOP

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>type D:\Test\1.txt
ab cd efgh N OL
ab ce efgh N OP
ab cd efgh N OP
C:\Users\Administrator>type D:\test\1.txt | findstr /r /i /c:"^ab cd.*N OP$"
ab cd efgh N OP

C:\Users\Administrator>

TOP

你要是觉得 findstr 不靠谱,这样好了
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /f "delims=" %%i in ('type a.txt') do (
  4.     set "s=%%i"
  5.     if "!s:~0,5!!s:~-4!" == "ab cdN OP" (echo;!s!)
  6. )
  7. pause
复制代码

TOP

返回列表