How can you find and replace text in a file using the Windows command-line environment? -


i writing batch file script using windows command-line environment , want change each occurrence of text in file (ex. "foo") (ex. "bar"). simplest way that? built in functions?

if on windows version supports .net 2.0, replace shell. powershell gives full power of .net command line. there many commandlets built in well. example below solve question. i'm using full names of commands, there shorter aliases, gives google for.

(get-content test.txt) | foreach-object { $_ -replace "foo", "bar" } | set-content test2.txt 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

visual studio - Deleting lines of code in a text editor -

What's the encoding type of Android 2.2 push message? -