title: Grep / Find oracle table name from UNIX Shell / SQL Script
body: <p>This is the sample update script in (*.sql) file. I have to extract oracle table name from the shell script / sql script in the displayed output below. Also I am attaching the source code below. I tried to accomplish by awk commands,</p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>awk -F'[=&amp;? ]' '{for (i=1;i&lt;NF;i++) if ($i == "from") print (i+1) }' $FILE
  </code></pre>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code>UPDATE|EVENT.SEASONAL_EVENT_SKU
  SELECT|PLANOGRAM_SKU
  SELECT|PLANOGRAM_VERSION
  SELECT|SEASONAL_EVENT_SKU
  </code></pre>
  
  <p><strong>EXAMPLE SCRIPT:</strong></p>
  
  <pre><code>update EVENT.SEASONAL_EVENT_SKU
  set SEAS_SKU_IND = 'Y'
  where SKU_NBR in ( select distinct sku_nbr
                 from
               (
                 select a.sku_nbr
                 from PLANOGRAM_SKU a,
                      PLANOGRAM_VERSION b
                 where a.plano_nbr between 9000 and 9999
                 and   a.plano_nbr        = b.plano_nbr
                 and   a.plano_version_id = b.plano_version_id
                 and   b.seas_plano_ind   = 'Y'
                 and   a.sku_nbr not in ( select d.sku_nbr
                                          from PLANOGRAM_SKU d,
                                               PLANOGRAM_VERSION e
                                          where d.plano_nbr between 9000 and 9999
                                          and   d.plano_nbr        = e.plano_nbr
                                          and   d.plano_version_id = e.plano_version_id
                                          and   e.seas_plano_ind &lt;&gt; 'Y')
                 union all
                 select f.sku_nbr
                 from SEASONAL_EVENT_SKU f
                 where f.sku_nbr not in ( select g.sku_nbr
                                          from PLANOGRAM_SKU g
                                          where g.plano_nbr between 9000 and 9999 )));
  
  COMMIT;
  </code></pre>
  
  <p>Let me know the better approach to do this for 'n' number of scripts. Thanks.</p>