• 1 reply
  • Latest Post - ‏2007-02-14T20:01:29Z by rayhiggs
232 Posts

Pinned topic extracting the lines between 2 strings of a file

‏2007-02-14T11:57:48Z |

I have a sql file and i need to extract the table names used in the sql file using a unix script. If i can extract the lines between the keywords 'FROM' and 'WHERE' in the file, my job is done. can somebody tell me how to do this using a shell script. If u can just let me know, how to extract the lines between 2 strings, it would be a great help.
just to indicate with an example , suppose the file contains :

select e.empno, e.deptno,d.deptname
from emp e, dept d where

from the above i would want to extract the strings present between FROM and WHERE using a script/unix command, so that i should effectively get "emp e,dept d "

Thanks in advance.
Updated on 2007-02-14T20:01:29Z at 2007-02-14T20:01:29Z by rayhiggs
  • rayhiggs
    1 Post

    Re: extracting the lines between 2 strings of a file

    sed -e '/from.*where/!d' -e 's/from //' -e 's/where//' filename