delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/17/08:30:04.1

From: mylo AT home DOT nl (Mylo)
Newsgroups: comp.os.msdos.djgpp
Subject: Appropriate tool to do this task?
Date: 17 Jul 2001 05:19:20 -0700
Organization: http://groups.google.com/
Lines: 44
Message-ID: <38cf9e1c.0107170419.34bcfbc3@posting.google.com>
NNTP-Posting-Host: 213.51.176.25
X-Trace: posting.google.com 995372361 6695 127.0.0.1 (17 Jul 2001 12:19:21 GMT)
X-Complaints-To: groups-support AT google DOT com
NNTP-Posting-Date: 17 Jul 2001 12:19:21 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

Wondering whether anyone can help...
Working on a script in DOS where I'm parsing information in line by
line from a file FILE1.TXT. As each line is processed I'm trying to
find the equivalent string of text in a second file (FILE2.TXT). For
example

FILE1.TXT
=========
Apples
Apples and Oranges
Bananas
Pineapples

FILE 2.TXT
==========
Apples and Oranges only in this file.

The script needs to pull out the correct information based on the
contents of FILE 2, i.e. FILE 1 is the dictionary file... note that
Apples exists twice... that's a bit of a problem particularly when I'm
after Apples and Oranges, not just Apples, so I need to deal with
spaces as well.....

Apart from the aforementioned 'Apples' problem, I'm at the following
impasse... I've tried using the DOS FOR command but it's quite
limited. For example,

CD DUMMYDIR
FOR %%A IN (*) DO FIND /I "%%A" FILE2.TXT

sort of works... provided I follow 8+3 naming conventions in the
DUMMYDIR I've created and manually create my FILE1.TXT entries as
files under that directory. I've experimented with this as the FOR
command in DOS does not appear to support parsing of input files, to
the equivalent NT shell command FOR/F... have not found any alternate
tools for doing this.

Is there an equivalent of performing an operation such as this using
tools such as GREP or SED ???
 
Regards
Mylo

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019