▽1
●
freemann ベストアンサー |
Windowsであれば、Powershellで可能です。
param([switch] $r, $in,$ex,$regex) function funcReplace{ Param([string] $path, [string] $regex) $enc = [System.Text.Encoding]::GetEncoding("Shift-JIS") $stream = new-object System.IO.StreamReader($path, $enc) $text = $stream.ReadToEnd() $stream.Close() $ostream = new-object System.IO.StreamWriter($path, $false, $enc) $ostream.Write( ($text -replace $regex, "") ) $ostream.Close() } if($r -eq $false){ Get-ChildItem * -Include $in -exclude $ex | %{ funcReplace -p $_ -r $regex} }else{ Get-ChildItem * -Include $in -recurse -force -exclude $ex | %{ funcReplace -p $_ -r $regex} }
上記のコードを、Replace.ps1というファイルに保存したとすると、
Replace.ps1 -r -in *.txt (?s:^.*?(?:=明日の))
で行けます。
一応私の環境で試してはいますが、本番をする前にコピーしたファイルで試してみてからにしてください。