gpt4 book ai didi

batch-file - 如何在每 (n) 行后插入空行?

转载 作者:行者123 更新时间:2023-12-01 02:24:20 25 4
gpt4 key购买 nike

我有这个脚本:

@ECHO OFF

(FOR /f tokens^=2^ delims^=^" %%a IN ('findstr /l "\<SOMETHING=\>" FILE.vav') DO (Echo | Set /p =%%a,)) >> Results.txt
现在的结果是这样的:
SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING, 
.但我需要插入 空行每 5 个结果后,结果应如下所示:
SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING,
//blank line
SOMETHING, SOMETHING, SOMETHING, SOMETHING, SOMETHING,
// blank line
SOMETHING, SOMETHING, SOMETHING,
可能的解决方案是 FOR /LIF ,但我想不通。

最佳答案

尝试这个:

ECHO OFF &SETLOCAL 
(FOR /f tokens^=2^ delims^=^" %%a IN ('findstr /l "\<SOMETHING=\>" FILE.vav') DO (
<NUL Set /p =%%a,
SET /a counter+=1
SETLOCAL ENABLEDELAYEDEXPANSION
SET /a counter%%=5
IF !counter! equ 0 ECHO(
ENDLOCAL
)
)>Results.txt
TYPE results.txt

关于batch-file - 如何在每 (n) 行后插入空行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17811358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com