Extracting a line value from a text file

  • Thread starter Thread starter domw001
  • Start date Start date
D

domw001

I have a text file(line.txt)as follows:

1. line1
2. LINE 2
3. line 03
4. line 004
5. line 55555

I need to enter a line number, parse the text file to find the line
number and put the value in a %variable%

Example
1.using set /p command, enter a line number e.g. 2
2.parse line.txt to find line 2
3.put the value "LINE 2" into %line_val%


Can anyone help.

D.
 
I have a text file(line.txt)as follows:

1. line1
2. LINE 2
3. line 03
4. line 004
5. line 55555

I need to enter a line number, parse the text file to find the line
number and put the value in a %variable%

Example
1.using set /p command, enter a line number e.g. 2
2.parse line.txt to find line 2
3.put the value "LINE 2" into %line_val%


Can anyone help.

D.
[1]@echo off
[2]set /p yln=Select which line ?
[3]set ysd=
[4]for /f "tokens=1*" %%i in (line.txt) do if %%i==%yln%. set ysd=%%j
[5]echo line selected was %ysd%
[6]set yln=

Each line begins [number]. Lines will be wrapped in transmission and need to
be rejoined. The [number] at the beginning of each line needs to be removed.

You'll find a lot of data if you care to look at alt.msdos.batch.nt

HTH

....Bill
 
Back
Top