rav*_*nth 36
我会给你一个PowerShell的全部答案.您可以使用"添加内容"或"设置内容"cmdlet.
Set-Content覆盖目标文件,Add-Content附加到文件.
Set-Content -Value "Test1" -Path C:\Scripts\Scratch\test.txt
Add-Content -Value "Test" -Path C:\Scripts\Scratch\test.txt
或者,您也可以使用Out-File.
"Test" | Out-File -FilePath C:\Scripts\Scratch\test.txt -Append
你需要的命令是echo:
 echo Text >> textFile.txt
这个链接应该有助于学习Windows命令.
小智 5
以下是用于创建内容并将其添加到文本文件中的示例代码:
$text = Hello World
# This is to create file:
$text | Set-Content MyFile.txt
# Or
$text | Out-File MyFile.txt
# Or
$text > MyFile.txt
# This is to write into a file or append to the text file created:
$text | Add-Content MyFile.txt
# Or
$text | Out-File MyFile.txt -Append
# Or
$text >> MyFile.txt
| 归档时间: | 
 | 
| 查看次数: | 53054 次 | 
| 最近记录: |