如何通过使用Windows批处理脚本提供行号来从文件中获取特定行 [英] how to get a specific line from a file by giving the line number using windows batch script

查看:456
本文介绍了如何通过使用Windows批处理脚本提供行号来从文件中获取特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过使用Windows批处理脚本给出行号来获取文件中的特定行

how to get a specific line from a file by giving the line number using windows batch scrip

推荐答案

尝试此代码。请注意,批处理文件将忽略空行。

Try this code. Note that batch files will ignore blank lines.

@echo off

set number = 30

设置File = MyFile.txt

设置n = 1

for / F" delims =" %% a in(%File%)调用:Sub %% a

goto:eof



:Sub

如果%n%==%number%echo%*

set / an =%n%+ 1

如果您的文件包含空行,那么您可以使用此混合批处理文件:

If your file contains blank lines then you could use this hybrid batch file:


这篇关于如何通过使用Windows批处理脚本提供行号来从文件中获取特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆