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
Post a Comment