喜我试着找到一个脚本,可以让我显示行号#行号和#以及#线 - #从一个批处理文件的文本文件?我在这里找到这个脚本在这个网站。
Hi I'm tryin' to find a script that will let me display "linenumber# and linenumber# as well as lines#-#" from a text file in a batch file? I found this script here on this site..
@echo off setlocal enabledelayedexpansion if [%1] == [] goto usage if [%2] == [] goto usage SET /a counter=0 for /f "usebackq delims=" %%a in (%2) do ( if "!counter!"=="%1" goto exit echo %%a set /a counter+=1 ) goto exit :usage echo Usage: head.bat COUNT FILENAME :exit和它的伟大工程:)但它抓住的行数从文本文件的顶部。我想能够显示在文本文件中的某些线,以及一个范围,如果可能..
And it works great :) But it grabs the number of lines from the top of the text file. I want to be able to display certain lines in the text file, as well as a range if possible..
EG:我有30行的文本文件,我想显示1-4行; 7-11; 13; 17-20; 22; 26安培; 29
EG: I have a text file with 30 lines, and I want to display lines 1-4; 7-11; 13; 17-20; 22; 26 & 29
推荐答案下面是上面的示例批处理文件的一个简单的修改。复制code以下为文件并将其命名为LineDisplay.bat - 它采用FirstLineNumber和LastLineNumber作为参数。例如:LineDisplay test.txt的12月30日(读线12-30)
Here's a simple modification of the sample batch file above. Copy the code below to file and name it "LineDisplay.bat" - it takes the FirstLineNumber and LastLineNumber as parameters. Example: LineDisplay test.txt 12 30 (to read lines 12-30)
@echo off setlocal enabledelayedexpansion if [%1] == [] goto usage if [%2] == [] goto usage if [%3] == [] goto usage set /a FirstLineNumber = %2 set /a LastLineNumber = %3 echo Reading from Line !FirstLineNumber! to !LastLineNumber! SET /a counter=1 for /f "usebackq delims=" %%a in (%1) do ( if !counter! GTR !LastLineNumber! goto exit if !counter! GEQ !FirstLineNumber! echo !counter! %%a set /a counter+=1 ) goto exit :usage echo Usage: LineDisplay.bat FILENAME FirstLineNumber LastLineNumber :exit下面是一条线,一个很好的教程创建批处理文件 HTTP: //vtatila.kapsi.fi/batch_tutorial.html
Here's a line to a nice tutorial on creating batch files vtatila.kapsi.fi/batch_tutorial.html
更多推荐
从显示文本文件行批处理文件
发布评论