我有一个简单的批处理文件,它从批处理文件中读取最后10行,然后输出这10行新的txt文件,但是我需要它输出为逗号分隔的行/字符串。
@echo off
for /f %%i in ('find /v /c "" ^< C:\Path To File\File.txt') do set /a lines=%%i
set /a startLine=%lines% - 10
more /e +%startLine% C:\Path To File\File.txt > Output.txt另外,是否可以在新的txt文件中反转行顺序,以便最后一行位于逗号分隔行的开头。
我想要的例子:
line1 line2 line3 line4
输出为
line4, line3, line2, line1发布于 2017-01-11 22:37:39
这个小型powershell脚本将完成:
$Lines = Get-Content .\Lines.txt|select -last 10
($Lines[($Lines.Length-1)..0]) -join(', ')|Set-Content Lines-new.txt以批次包装在主题上:
@echo off
Powershell -command "($Lines=GC .\Lines.txt|select -last 10);(($Lines[($Lines.Length-1)..0]) -join(' ')|Set-Content Lines-New.txt)"https://stackoverflow.com/questions/41592755
复制相似问题