Reputation: 480
When I run the code, it outputs FIND: Parameter format not correct
and The process tried to write to a nonexistent pipe.
. From this, I'm pretty sure the for loop can't handle the pipe and/or redirection. I'm not sure what to do from here, I've tried running it outside a loop, and that works fine, but inside the loop it chucks the dummy. Does anyone know why, or how I can fix this?
@ECHO OFF
setlocal enabledelayedexpansion
for /F "tokens=*" %%a in (set_1.txt) do (
type set_2.txt | find %%a > nul
if !errorlevel! EQU 1 (
echo %%a
)
)
endlocal
pause
And before anyone says it, I'm aware this is not the most efficient method for finding strings in files, but it doesn't matter for the file sizes I'm dealing with.
Upvotes: 1
Views: 1459
Reputation: 82418
type someFile | find word
simply fails, as find requires a "word" in quotes.
So the solution is to change your line to
type set_2.txt | find "%%a" > nul
if !errorlevel! EQU 0 (
....
Or even simpler
type set_2.txt | find "%%a" > nul || echo %%a not found
Upvotes: 4