Wednesday, June 29, 2011

An example for replacing strings with SED in DOS files

sed --expression="s/Some text with slash here... \/ ala bala/Some other text/g" %2 > %2.tmp
@IF NOT %ERRORLEVEL% == 0 GOTO ERROR
@copy %2.tmp %2 /y
@IF NOT %ERRORLEVEL% == 0 GOTO ERROR

@rem other code here...
@Goto :END

:ERROR
@echo Error :(

:END


Attention: sed.exe is an utility from UnxUtils for DOS/Windows (and an standard binary for Linux distributions)

No comments:

Post a Comment