The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
extracting lines from a file trichyselva UNIX for Dummies Questions & Answers 4 09-02-2008 06:18 AM
Extracting lines between 2 strings only if the pattern patches simran Shell Programming and Scripting 5 04-23-2008 04:58 PM
extracting a set of strings from a text file Deanne Shell Programming and Scripting 2 09-20-2007 11:31 PM
Help with extracting strings from a file cmsdelhi Shell Programming and Scripting 7 01-12-2007 09:49 AM
extracting lines from a file pradeepthanraj Shell Programming and Scripting 1 11-15-2005 09:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-14-2007
babloo babloo is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 1
Extracting the lines between 2 strings of a file

Hi,

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.
Thanks in advance.
  #2 (permalink)  
Old 02-14-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
sed -n "/FROM/,/WHERE/p" file
  #3 (permalink)  
Old 02-14-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,414
Another way :
Code:
awk '/FROM/,/WHERE/' file

Jean-Pierre.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0