[英]How to read text file line by line which is excessing characters in batch file? Limiting the line length is allowed.(Windows, batch script)
[英]How to read file line by line using batch
源文件以以下方式存在:-
ABC
DFC
中国农业发展银行
我正在使用下面的代码来打印文件中的每一行。
for /f "tokens=* delims=" %%a in ('type input.txt') do (
set line=%%a
echo %line%
)
但输出是
中国农业发展银行
中国农业发展银行
中国农业发展银行
该怎么办? 所需的输出是:
ABC
DFC
中国农业发展银行
除非您特别需要操纵该行或将最后一行的内容保存在变量中,否则绝对不需要使用For
循环:
Type input.txt
@Squashman确实提供了答案,但是在这里写出来:
setLocal EnableDelayedExpansion
for /f "tokens=* delims=" %%a in ('type input.txt') do (
set line=%%a
echo !line!
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.