The code below shows the output of my ping that I wish to finally store in a file but first I want to tidy it up a little.
Code: Select all
Pinging sew36server.jp.eu.sew [10.16.4.235] with 32 bytes of data:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 184ms, Maximum = 230ms, Average = 206ms
I would like to remove the blank lines and the leading spaces.
Two issues
1. Ignore blank lines
2. set a non-blank line to a variable (string or otherwise) then manipulate it.
Taking issue 1 first
The body of the for loop is then called with the variable value(s) set to the found token string(s). By default, /F passes the first blank separated token from each line of each file. Blank lines are skipped.
The quote above (from a web site) implies that a for loop will ignore blank line. I have tried
Code: Select all
for /f "eol=" %%a in (asiaPacificPing.txt) do echo %%a
and
Code: Select all
for /f "eol= " %%a in (asiaPacificPing.txt) do echo %%a
and
Code: Select all
for /f %%a in (asiaPacificPing.txt) do echo %%a
without success. How does one skip blank lines in a file using for (or any other method)?
Taking issue 2 now
How does one assign a line to a variable, say str?
I have tried
Code: Select all
for /f %%a in (asiaPacificPing.txt) do set str=%%a
but that does not seem to work.
Please help before I kill my windows machine./