我有一个简单的文本文件,我需要一个 powershell 脚本来替换文件内容的某些部分。
我当前的脚本如下:
$content = Get-Content -path "Input.json"
$content -Replace '"(\d+),(\d{1,})"', '$1.$2' | Out-File "output.json"
是否可以像这样在没有内容变量的情况下将其写在一行中?
Get-Content -path "Input.json" | ??? -Replace '"(\d+),(\d{1,})"', '$1.$2' | Out-File "output.json"
我不知道如何在没有 $content 变量的情况下在第二个命令中使用第一个 get-content 命令行开关的输出?是否有自动 powershell 变量
是否可以在管道中进行比替换更多的替换。
Get-Content -path "Input.json" | ??? -Replace '"(\d+),(\d{1,})"', '$1.$2' | ??? -Replace 'second regex', 'second replacement' | Out-File "output.json"