substitution - substituting a string with cmd with wildchar -


i have text file me contains lines

line1 line2 helloabcd line4 

i want create batch file edit helloabcd line %this% dont know abcd know hello. how can it?

i tried using fart.exe, never substituted when there wildcard

fart.exe txt1.txt hello* %this% 

can done using pure cmd, or fart?

thanks in advance reply

edit: ok tried fart.exe txt1.txt hello %this% got %this%abcd instead of %this%

try this:

@echo off &setlocal set "this=wqreqwrq" /f "delims=" %%i in ('^<txt1.txt findstr /n "^"') (     set "line=%%i"     setlocal enabledelayedexpansion     set "line=!line:*:=!"     if not "!line!"=="!line:hello=!" set "line=%this%"     (echo(!line!)>>output.txt     endlocal ) 

output in output.txt.

edit: add. "!" removed.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -