私は同等のものを書こうとしています
find -name "*.xml" | xargs grep -l "Search String"
| xargs perl -p -i -e 's/Search String/Replace String/g'
パワーシェルで。これが私が思いついたものです。
Get-ChildItem 'D:\code\cpp\FileHandlingCpp\input - Copy' -Recurse |
Select-String -SimpleMatch $src_str |
foreach{(Get-Content $_.path) | ForEach-Object { $_ -replace $src_str, $target_str }}
「別のプロセスで使用されているため、プロセスはファイルにアクセスできません」というエラーが表示されます。そのため、以下に示すように複数行のバージョンを考え出しました。 $src_str. $src_str の何が問題になっていますか?
$src_str="<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>"
$target_str=""
echo $src_str
foreach ($var in (Get-ChildItem 'D:\code\cpp\FileHandlingCpp\input - Copy' -Recurse
| Select-String -SimpleMatch $src_str).Path)
{
(Get-Content $var) | ForEach-Object { $_ -replace $src_str, $target_str }
| Set-Content $var
}