powershell - 如何在没有中间文件的情况下将文件附加到目标文件的开头?
问题描述
我想在没有中间文件的情况下将文件 toppart_ABC.txt(包含'ABC')附加到destinationfile_DEF.txt(包含'DEF')的开头。
如果我尝试
Add-Content -Path .\destinationfile_DEF.txt -Value (Get-Content .\toppart_ABC.txt)
这会更改正确的文件destinationfile_DEF.txt,但内容错误-它将文本放在底部,即defabc
如果我尝试
Add-Content -Path .\toppart_ABC.txt -Value (Get-Content .\destinationfile_DEF.txt)
这会更改错误的文件 toppart_ABC.txt,但具有正确的内容,即 abcdef
理想情况下寻找一个班轮,但不是至关重要的
解决方案
如果您不反对只重写文件,则可以Set-Content
在检索两个文件内容后执行:
Set-Content -Path .\destinationfile_DEF.txt -Value (Get-Content .\toppart_ABC.txt,.\destinationfile_DEF.txt)
推荐阅读
- python - 在数据框中的列之间查找一个 - 多个匹配项
- python - 何时在 python 和 django 中使用 *args , *kwargs
- c - OMP 复制矩阵的最佳方式
- c - 为另一个程序提供带有选项的程序名称
- android - 片段中未调用 onRequestPermissionsResult,未打印日志
- c++ - 将一个动态结构数组复制到另一个动态结构数组
- mysql-error-1452 - 错误 con MySQL,relacionado con la 外键
- amazon-web-services - aws athena 创建标记的 s3 对象
- amazon-ec2 - 无法从 ec2 prod 机器远程登录 SMTP 服务器
- java - 如何仅减去两个 Java.util.date 对象的日期部分?