Powersheel批量替换指定目录下文件中的指定字符串


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

遇到一个需求,替换某目录下每个文件中指定的多个字符串,用powershell解决

$fileList = Get-ChildItem  'N:\ps\ClassLibrary\' -recurse *.cs | %{$_.FullName}
Foreach($file in $fileList)
{ 
    (Get-Content $file) | 
	Foreach-Object {
		$_ -replace 'bdOrderinfo_save','Orderinfo_save'-replace bdOrderinfo_sel','Orderinfo_sel'
		
		}  | 
	Out-File $file

}