本帖最后由 tmplinshi 于 2013-10-22 22:56 编辑
- @echo off
- setlocal
-
- set listFile="a.txt"
- set inFile="b.txt"
- set outFile="c.txt"
-
- set /p Line1=<%listFile%
-
- (
- for /f "tokens=*" %%a in (' findstr /n .* %inFile% ') do (
- set ThisLine=%%a
-
- setlocal enabledelayedexpansion
-
- if "!ThisLine:restore controlfile from '=!" neq "!ThisLine!" (
- for /f "delims='" %%a in ("!ThisLine!") do (
- set ThisLine=%%a'!Line1!';
- )
- )
- echo,!ThisLine:*:=!
-
- endlocal
- )
- ) >%outFile%
复制代码 或者用 sed:- set /p Line1=<a.txt
- sed -r "s|(restore controlfile from )'[^']+'|\1'%Line1%'|ig" b.txt >c.txt
复制代码
|