0

As per my corrected answer to another question it seems that Windows XP doesn't strip <cr>'s from for /f output.

How can I test for the existance of <cr>'s in the output?

What I currently have is:

for /f "tokens=1,2,3* %%a in ('ping -n 1 example.com') do (
   if not "x%%a"=="¶" ( echo %%a ) else ( echo.>null )
)

but no matter what I do:

 2) delims= ¶

 3) if not "x%%a"==""

 4) if not "x%%a"==" "

 5) if not "x%%a"==" "

... I cannot seem to get the if to match the in the var with any combination of the above.

Community
  • 1
  • 1
user66001
  • 774
  • 1
  • 13
  • 36

1 Answers1

0

Using the FOR statement, there really is no way that I know of to consistently check for empty lines.

The FOR statement actually skips blank lines, which is what a carriage-return only is, just a blank line.

If it is able to check, you just need to check for an empty string. Like if "%%x"=="" echo Yes!

But try this at the command line:

for /f "tokens=*" %x in ('for /?') do @echo %x

Then compare it to the output of:

for /?

And you will see that (usually*) FOR does not include empty lines.

*I have seen it happen on occasion (usually when it's a pain), but I've never been able to reproduce it consistently.

Edited Answer

James K
  • 4,005
  • 4
  • 20
  • 28
  • It doesn't appear to me that the FOR statement skips blank lines, on Win XP. See the "[my corrected answer to another question](http://stackoverflow.com/a/14642856/1126551)" in the question for more. – user66001 Feb 02 '13 at 19:19