- @echo off
- set "File=a.txt"
- set "Line=2"
- set "Str=qwert"
- set n=0
-
- (for /f "delims=" %%a in ('findstr /n .* "%File%"') do (
- set /a n+=1
- set var=%%a
- setlocal enabledelayedexpansion
- if !n!==%Line% echo;!Str!
- echo;!var:*:=!
- endlocal
- )) > "%temp%\~.txt"
-
- move "%temp%\~.txt" "%File%"
复制代码
|