title: Batch reading file info
body: <p>so i need to write a batch, that reads a .log file and does certain tasks with it.<br>
  1. Count the number of logins<br>
  2. Show ip address and file of successful login cases and at the end count how many of them took place  (error code 200)
  3. Show ip address and file of unsuccessful login cases and at the end count how many of them took place (error code 404)  </p>
  
  <p>here is my program. </p>
  
  <pre><code>@echo off
  :pasirinkimas
  cls
  echo Iveskite 1, jei norite pamatyti visu bandymu prisijungti skaiciu.
  echo Iveskite 2, jei norite pamatyti informacija apie visus sekmingus prisijungimus.
  echo Iveskite 3, jei norite pamatyti informacija apie visus nesekmingus prisijungimus.
  echo Iveskite 4, jei norite baigti darba.
  
  set /p pasirinkimas= Iveskite pasirinkima: 
  
  if %pasirinkimas% == 1 goto bandymai
  if %pasirinkimas% == 2 goto sekme
  if %pasirinkimas% == 3 goto nesekme
  if %pasirinkimas% == 4 goto pabaiga
  goto pasirinkimas
  
  :bandymai
  echo Prisijungimu skaicius:
  findstr "^[1-9]" apache.log | find /v "" /c 
  pause&gt;null
  goto pasirinkimas
  
  :sekme
  findstr /c:" 200 " apache.log&gt;null
  for /f "tokens=1,7" %%G in (null) do echo %%G %%H
  echo Sekmingu prisijungimu skaicius:
  find /c " 200 " null 
  pause&gt;null
  goto pasirinkimas
  
  :nesekme
  findstr /c:" 404 " apache.log&gt;null
  for /f "tokens=1,7" %%G in (null) do echo %%G %%H
  echo Nesekmingu prisijungimu skaicius:
  find /c " 404 " null  
  goto pasirinkimas
  
  pause&gt;null
  
  :pabaiga
  exit  
  </code></pre>
  
  <p>it works 100%. I just wanted to as if i could achieve the same result without redirecting <strong>findstr</strong> output to null file? or should i not worry about it?
  here is my attempted version of the code without redirecting output to null file  </p>
  
  <pre><code>:sekme
  findstr " 200 " apache.log | find /v " " 
  for /f "tokens=1,7" %%G in ('findstr " 200 " apache.log') do echo %%G %%H  
  </code></pre>
  
  <p>with this the program DOES display the needed output on the screen but it takes about 8-10 seconds to do that (if file was bigger the time would grow i believe). plus i have no idea how to count the output lines. tried to do it on the same principle as in the first task <strong>:bandymai</strong> but failed miserably.<br>
  Can anyone help?</p>
  
  <p>EDIT:
  couple of log file lines </p>
  
  <pre><code>67.195.112.96 - - [22/Feb/2010:00:06:03 +0200] "GET /www/kurpiai/dalyviai/?did=118 HTTP/1.0" 200 41119 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)"
  67.195.112.96 - - [22/Feb/2010:00:06:04 +0200] "GET /www/css/master.css HTTP/1.0" 304 145 "http://jazz.lt/www/kurpiai/dalyviai/?did=118" "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)"
  88.118.90.240 - - [22/Feb/2010:00:09:43 +0200] "GET /www/kurpiai/dalyviai/?did=30 HTTP/1.1" 200 13140 "http://www.google.lt/search?hl=lt&amp;source=hp&amp;q=gintaras+stankunas&amp;btnG=Google+Paie%C5%A1ka&amp;meta=&amp;aq=f&amp;oq=" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5"
  88.118.90.240 - - [22/Feb/2010:00:09:43 +0200] "GET /www/javascript/swfobject.js HTTP/1.1" 200 8969 "http://www.jazz.lt/www/kurpiai/dalyviai/?did=30" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5"
  88.118.90.240 - - [22/Feb/2010:00:09:43 +0200] "GET /www/kurpiai/dalyviai/?did=30 HTTP/1.1" 200 40199 "http://www.google.lt/search?hl=lt&amp;source=hp&amp;q=gintaras+stankunas&amp;btnG=Google+Paie%C5%A1ka&amp;meta=&amp;aq=f&amp;oq=" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5"
  </code></pre>