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

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I am writing a batch file script using Windows command-line environment and want to change each occurrence of some text in a file (ex. "FOO") with another (ex. "BAR"). What is the simplest way to do that? Any built in functions?

Answers

http://en.wikipedia.org/wiki/Windows_PowerShell http://en.wikipedia.org/wiki/Windows_PowerShell

(Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/60034/how-can-you-find-and-replace-text-in-a-file-using-the-windows-command-line-envir

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils