alright. have 2 files file1 , file2
file1
line1 helloa hellob line2
file2
line3 helloc hellod helloe line4
i want replace hello
lines in file1 of file2, lines together, ideas?
can done using statement?
for /f "tokens=1,* delims==" %%a in ('find "hello" ^< file2') set helloa=%%b
thanks in advance answers
try this:
@echo off &setlocal /f "tokens=1*delims=:" %%i in ('^<file2.txt findstr /n "hello"') set "#%%i=%%j" (for /f "delims=" %%i in (file1.txt) ( set "line=%%i" setlocal enabledelayedexpansion if not "!line!"=="!line:hello=!" ( endlocal if not defined flag ( /f "tokens=1*delims==" %%a in ('set "#"') echo(%%b set "flag=true" ) ) else ( echo(!line! endlocal ) ))>output.txt
output in output.txt
.
edit: improved behaviour concerning delayed expansion
.
Comments
Post a Comment