Computer Hope

Microsoft => Microsoft DOS => Topic started by: vinoth124 on September 17, 2008, 05:33:16 AM

Title: Read a particular word using DOS?
Post by: vinoth124 on September 17, 2008, 05:33:16 AM
Hi,

Is there is any possiblity to read a particular word in a text file. I know where the word will start and end.

For example:

Consider the text file contains the following content...,

ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ

I need to read the character from 4th position to 9th position of the line1.
i.e., I need to get "DEFIJK" alone from this text file.

Will you please help me to resolve the same.

Thanks in advance...,

With Regards,
Vinoth R
 :)
Title: Re: Read a particular word using DOS?
Post by: devcom on September 17, 2008, 06:01:42 AM
   
The easiest way:
Code: [Select]
@echo off
set data=ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM NOPQRSTUVWXYZ
echo %data%
set data1=%data:~3,3%
set data2=%data:~8,3%
echo %data1%%data2%
pause