Help with grep in for loop

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with grep in for loop

#16 Post by foxidrive » 15 Jun 2012 06:57

doscode, show us the source code and then state what you need from it, and give an example.

People will quickly lose interest if you ask for one thing, but then you change what you need in the next posts.

doscode
Posts: 175
Joined: 15 Feb 2012 14:02

Re: Help with grep in for loop

#17 Post by doscode » 15 Jun 2012 09:51

I have the code done, for the second site:
http://www.proxynova.com/proxy-server-list/

Code: Select all

@echo off 
Setlocal EnableDelayedExpansion
SET proxy_1=Proxy_1.htm
SET proxy_2=Proxy_2.htm         

for /f "delims=" %%x in (delimiter.ini) do set TAB=%%x
 
if not exist %proxy_1% (
  echo File not found
  pause
  exit
)

REM FOR /F "tokens=7,12,15 delims=<>" %%A IN ('grep -B 25 "</td></tr></tbody></table>" !proxy! ^| grep high') DO ( echo %%A %%B %%C )

FOR /F "tokens=3,4,5 delims=<>" %%A IN ('grep -B 810 -E "<th colspan=.10.>&nbsp;</th>" !proxy_2! ^| grep -E ^"row_proxy^|port^|country^|proxy_^" ') DO (
  REM echo 1: %%A 2:%%B 3:%%C
  if "%%C" == "/span" SET ip=%%B
  if "%%C" == "/a" SET port=%%B
  if "%%B" == "/a" SET location=%%A
  if "%%B" == "/span" (
    SET A=%%A
    SET A=!A:"=$!
    FOR /F "tokens=1,2,3 delims=$ " %%S IN ("!A!") DO (
    SET type=%%U
    SET ready=1
    )
  )
if !ready!==1 (
  echo IP:!ip!:!port! in !location! is !type!
  SET ready=0
  pause
)
)


Post Reply