本质上,我想从file.txt中读取内容
苹果 香蕉 胡萝卜
并写入newfile.txt,使其包含内容
苹果香蕉胡萝卜
我需要在没有安装权限的Windows计算机上执行此操作。
我试过了
set row=
for /f %%x in (file.txt) do set row=%row% %%x
echo row > newfile.txt
Run Code Online (Sandbox Code Playgroud)
并且我尝试使用PowerShell语句(无法运行PowerShell脚本)而不是CMD样式的for循环。
powershell -Command "(Gc file.txt) | Foreach-Object -Process {set row=%row% _$} | Out-File newFile.txt"
Run Code Online (Sandbox Code Playgroud)
但都产生一个空文件。有没有办法做到这一点?