Computing.Net > Forums > Programming > How to read the 3rd line from the T

How to read the 3rd line from the T

Reply to Message Icon

Original Message
Name: vinoth124
Date: June 15, 2008 at 23:36:54 Pacific
Subject: How to read the 3rd line from the T
OS: Windows XP
CPU/Ram: NA
Model/Manufacturer: NA
Comment:

Hi Friend,

In batch code, is it possible to read a particular line from the text file.

For eg.,
Text file "test1.txt" contains the following text....

data1
data2
data3
data4
data5


I need to read the 3 line of the "test1.txt" file and print that line alone
(Ie.., It should echo the 3 line alone "data3")

Is there any option to resolve this issue....

Thank in Advance.

Urs,
Vinoth


Report Offensive Message For Removal


Response Number 1
Name: klint
Date: June 16, 2008 at 01:29:56 Pacific
Subject: How to read the 3rd line from the T
Reply: (edit)

@echo off
for /f "skip=2 delims=" %%a in (file.txt) do (
echo Third line is "%%a"
goto :next
)
:next
echo Done.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: How to read the 3rd line from the T

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge