Is there any sed like utility for cmd.exe?

Jakub Šturc picture Jakub Šturc · Sep 24, 2008 · Viewed 223.5k times · Source

I want to programmatically edit file content using windows command line (cmd.exe). In *nix there is sed for this tasks. Is there any useful native equivalent in windows?

Answer

Jakub Šturc picture Jakub Šturc · May 17, 2011

Today powershell saved me.

For grep there is:

get-content somefile.txt | where { $_ -match "expression"}

or

select-string somefile.txt -pattern "expression"

and for sed there is:

get-content somefile.txt | %{$_ -replace "expression","replace"}

For more detail see Zain Naboulsis blog entry.