- @echo off
- set "file=a.txt"
- set "str=bat"
- findstr /n .* "%file%" >"%temp%\.tmp"
- (for /f "usebackq delims=" %%a in ("%temp%\.tmp") do (
- set var=%%a
- SetLocal EnableDelayedExpansion
- if "!var:%str%=!" neq "!var!" echo,
- echo,!var:*:=!
- EndLocal
- )) >"%file%"
- del "%temp%\.tmp"
复制代码
|