如何用power覆盖文件内容shell
how to overwrite file content with power shell
我是 Powershell 的新手。你如何在 powershell 中覆盖文件?现在写在下面的代码是附加的。我想用以下新信息完全覆盖文件。
$一些信息 |添加内容 $FileName
使用 Set-Content
而不是 Add-Content
。
Set-Content
和Add-Content
的区别:
Add-Content
=>追加
Set-Content
=> 替换内容
你也可以Out-File
'Some content' | Out-File -FilePath c:\windows\temp\file.log
我是 Powershell 的新手。你如何在 powershell 中覆盖文件?现在写在下面的代码是附加的。我想用以下新信息完全覆盖文件。
$一些信息 |添加内容 $FileName
使用 Set-Content
而不是 Add-Content
。
Set-Content
和Add-Content
的区别:
Add-Content
=>追加
Set-Content
=> 替换内容
你也可以Out-File
'Some content' | Out-File -FilePath c:\windows\temp\file.log