Computing.Net > Forums > Windows XP > Find and replace string in a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Find and replace string in a file

Reply to Message Icon

Name: rsl
Date: July 26, 2005 at 02:20:12 Pacific
OS: Win XP
CPU/Ram: 1gb
Comment:

Hi,

I want to find a string from a file and replace a string using a bat file. I have tried with findstr to find a string but not sure how to replace the string.

For example, in a file test.bat

string is HOST_NAME=a
I want to replace this string value as HOST_NAME=b.

Thanks.




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 26, 2005 at 03:45:51 Pacific
Reply:

It's difficult, at best, witha a BAT, even in NT/XP.

I use either CHANGE.COM for text files up to about 32KB, or CHANGE.exe for files of any type/size.

Change

Change9.11


M2


If at first you don't succeed, you're about average.


0

Response Number 2
Name: rsl
Date: July 26, 2005 at 04:09:15 Pacific
Reply:

Hi M2,

Thanks for ur help.

Please let me know how to use this Change.com, what all parameters I need to pass?

Thanks.


0

Response Number 3
Name: Mechanix2Go
Date: July 26, 2005 at 04:30:23 Pacific
Reply:

Hi,

I guess I should put a readme in the ZIP. [doh]

The syntax is as follows:

change.com filename.ext "old string" "new string"

The new and old strings must be doublequoted and separated by EXACTLY ONE space.

So, for your example:

change.com test.bat "HOST_NAME=a" "HOST_NAME=b"

That's all one line, though it may get wrapped by the forum.

HTH


M2


If at first you don't succeed, you're about average.


0

Response Number 4
Name: rsl
Date: July 26, 2005 at 21:50:53 Pacific
Reply:

Hi,

Thanks, It worked ...

Again thanks a lot.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Find and replace string in a file

multiple find and replace www.computing.net/answers/windows-xp/multiple-find-and-replace/175096.html

find and replace text with the command prompt www.computing.net/answers/windows-xp/find-and-replace-text-with-the-command-prompt/176284.html

need to do find and replace in a text file , www.computing.net/answers/windows-xp/need-to-do-find-and-replace-in-a-text-file-/175911.html