Skip to content

Instantly share code, notes, and snippets.

@libliflin
Created July 29, 2016 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save libliflin/8c666fefce032ab23ac1fd14509f94be to your computer and use it in GitHub Desktop.
Save libliflin/8c666fefce032ab23ac1fd14509f94be to your computer and use it in GitHub Desktop.
Pull 616 Example SQL statements from the oracle 10g documentation.
@echo off
del examples-*
setlocal enableDelayedExpansion
rem wget -r -np https://docs.oracle.com/cd/B14117_01/server.101/b10759/statements_9014.htm#SQLRF01604
rem sift-tool.org
rem gnuwin32
rem sublime
rem lots of stackoverflow answers.
@FOR %%G IN (*.htm) DO if "" == "" (
sift -m "color=\"#330099\"[>]Examples.*" %%G | sift -m "<pre(.*?)>(.*?)</pre>" --replace "33333$2" > examples-%%G
rem could not use csplit; it was only giving one line?
set out_file_counter=0
for /f "usebackq delims=" %%L in (examples-%%G) do (
set line=%%L
if "!line:~0,5!" equ "33333" (
set /a out_file_counter=out_file_counter+1
)
echo !line!>>examples-%%G0!out_file_counter!
)
FOR %%K IN (examples-%%G0*) DO if "" == "" (
sift -m "33333(.*)" %%K --replace "$1" > %%K.sql
del %%K
)
)
endlocal
subl examples-statements_9014.htm01.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment