Re: Process one line of output only?...
- From: "NayJo" <CrawNOSPAMforMEford@xxxxxxxxxxxxxx>
- Date: Wed, 10 Jan 2007 16:36:17 -0500
"Al Dunbar [MS-MVP]" <alan-no-drub-spam@xxxxxxxxxxx> wrote in message
news:OBpO3rPNHHA.2028@xxxxxxxxxxxxxxxxxxxxxxx
"NayJo" <CrawNOSPAMforMEford@xxxxxxxxxxxxxx> wrote in message
news:u32E3qNNHHA.4912@xxxxxxxxxxxxxxxxxxxxxxx
When trying to use the for command to compare 2 files inline I only needto
know that the files match or that they don't. Since 'fc' does not setwithout
errorlevel I compare the output of fc to see if I get the message they
matched. If the files don't match I get many lines of data that I don't
necessarily need.
I tried putting a goto in the unmatch condition but this is making the
cmd.exe complain about mis-matched parentheses. Below is the code I am
trying to use. How can I modify this to succeed on match and fail on
mismatch without comparing every difference in the file?
for /F "skip=1 delims=* usebackq" %%L in (`fc /b reference_queries.txt
example_queries.txt`) do (
if "%%L"=="FC: no differences encountered" (
echo Settings are properly configured.
) ELSE (
REM jumpout as it is enough for me to know the files don't match
processing every difference.runs
echo Line is %%L
goto jumpout )
)
:jumpout
This yields ") not expected" error but if I remove the goto, the batch
just fine.
Why not just search the output of fc like this:
fc /b reference_queries.txt example_queries.txt | find /i "no
differences"
if errorlevel 1 (
echo/files differ
) else (
echo/files are the same
)
/Al
Thank you very much. That works for me with the addition of:
fc /b reference_queries.txt example_queries.txt | find /i "no differences"
nul
to suppress the output of "no differences" to the command line if the
comparison succeeds. This is the fix I will go with.
Thank you also Jens for the goto EOF solution. I haven't tried it since I
need to perform several of these comparisons in my batch file but in
conjunction with 'call sub' it may be a good option.
John C
.
- Follow-Ups:
- Re: Process one line of output only?...
- From: Jens Hastrup
- Re: Process one line of output only?...
- From: Mark V
- Re: Process one line of output only?...
- References:
- Process one line of output only?...
- From: NayJo
- Re: Process one line of output only?...
- From: Al Dunbar [MS-MVP]
- Process one line of output only?...
- Prev by Date: Re: Process one line of output only?...
- Next by Date: Re: Process one line of output only?...
- Previous by thread: Re: Process one line of output only?...
- Next by thread: Re: Process one line of output only?...
- Index(es):
Relevant Pages
|