help with nested for loop from files

October 1, 2010 at 09:14:36
Specs: Windows XP
I am trying to create a batch file that calls for each line from a file (C:\RCE.txt) and loop each line through a FIND command from another file (C:\pubs.txt)
if line 1 from C:\RCE.txt is found in C:\pubs.txt then do something )else( do something else.
then repeat process for line2, then line 3 until EOF is reached.
Can somebody please help me out with this?

See More: help with nested for loop from files

Report •


#1
October 1, 2010 at 17:53:19
download grep for windows ,then do this
C:\test> grep -f file1 file2 
C:\test> grep -f file2 file1

GNU win32 packages | Gawk


Report •

#2
October 1, 2010 at 20:32:29
one FOR will do.

=================================
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (myfile) do (
find "%%a" < somefile > nul
if errorlevel 1 echo do the not found thing
if not errorlevel 1 echo do the found thing
)


=====================================
Helping others achieve escape felicity

M2


Report •

#3
October 1, 2010 at 21:02:12
@M2, as usual, calling find for every word in myfile is slow. It would be better if there is some way to build up a string of search terms to be passed to findstr or find, eg

findstr /C:word3 /C:word2 /C:....  file
 

$0.02

GNU win32 packages | Gawk


Report •
Related Solutions


Ask Question