Re: Process one line of output only?...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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 need
to
know that the files match or that they don't. Since 'fc' does not set
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
without
processing every difference.
echo Line is %%L
goto jumpout )
)
:jumpout

This yields ") not expected" error but if I remove the goto, the batch
runs
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


.



Relevant Pages

  • Re: Process one line of output only?...
    ... errorlevel I compare the output of fc to see if I get the message they ... I tried putting a goto in the unmatch condition but this is making the ... REM jumpout as it is enough for me to know the files don't match ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Process one line of output only?...
    ... errorlevel I compare the output of fc to see if I get the message they ... I tried putting a goto in the unmatch condition but this is making the ... REM jumpout as it is enough for me to know the files don't match ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Process one line of output only?...
    ... errorlevel I compare the output of fc to see if I get the message they ... I tried putting a goto in the unmatch condition but this is making the ... REM jumpout as it is enough for me to know the files don't match ... On my computer fc does in fact return errorlevel .. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Invalid Use of Null
    ... > table I need to compare the above record to the below record for ... > have no control over and can't change. ... > GoTo 800 ... control-of-flow constructs such as Do loops, For loops, If...Then and ...
    (microsoft.public.access.modulesdaovba)
  • Re: Process one line of output only?...
    ... errorlevel I compare the output of fc to see if I get the message they ... I tried putting a goto in the unmatch condition but this is making the ... echo Settings are properly configured. ... REM jumpout as it is enough for me to know the files don't match ...
    (microsoft.public.win2000.cmdprompt.admin)