replace a letter in a sentence

February 2, 2011 at 21:32:22
Specs: Win 7 Ultimate , 4.17Ghz 8GB ram
How do i just change one letter of a sentence for example if i have a file that says:
hi how is your day howard
i want to change all h's to z's so it will look like this
zi zow is your day zoward

i have this

type config.ini | Findstr /v "a" >%temp%\1.txt
REM get the value of 4, suppose it is OFF now.
echo z >>%temp%\1.txt
type %temp%\1.txt >config2.ini

but it is not quite working it replaces the whole string with a h in it to z and cuts out the rest of the text


See More: replace a letter in a sentence

Report •


#1
February 3, 2011 at 00:07:49
hi try this

echo hi how is your day howard | sed 's/h/z/3'


Report •

#2
February 3, 2011 at 00:21:34
A different tack - one problem is that it will not output blank lines.:

@echo off>config2.ini
cls
setlocal enabledelayedexpansion

for /f "tokens=*" %%1 in (config.ini) do (
    set var=%%1
    set var=!var:h=z!&echo !var!>>config2.ini
    )

type config2.ini

Did you Google for an answer before asking the question?


Report •

#3
February 3, 2011 at 04:48:11
Thank you both very much!

Report •

Related Solutions


Ask Question