The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to replace a line content victorcheung Shell Programming and Scripting 13 04-21-2008 05:46 PM
How to convert C source from 8bit chars to 16bit chars? siegfried Shell Programming and Scripting 0 09-26-2007 11:26 AM
Deleting all content in a file from command line kingdbag UNIX for Dummies Questions & Answers 2 07-20-2006 04:00 PM
Using PERL to append chars to each line c0nn0r Shell Programming and Scripting 5 07-11-2006 04:55 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-11-2008
Registered User
 

Join Date: Apr 2008
Posts: 2
Get multiple line content between two chars

Hello -

I have a file that has the something like the following :

REM CREATE TABLE lots of text
REM table specifc creation text ;
REM ALTER TABLE lots of text
REM text specific to the the alter command
REM could be more lines of text;

What I need is to get all the lines for the ALTER TABLE statement up to the ending ; into a seperate file. There are multiple statements within the file and some could be one line some could span more than one line but they all end in a ;

Thanks in advance for your help.
Feliz
Reply With Quote
Forum Sponsor
  #2  
Old 04-11-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Code:
sed -n '/ALTER TABLE/,/;/p' file
You're not saying you want to remove the REMs at the beginning of line, so I didn't do that. If you want it after all, try something like

Code:
sed -n -e '/ALTER TABLE/,/;/{' -e 's/^REM //p' -e } file
Reply With Quote
  #3  
Old 04-11-2008
Registered User
 

Join Date: Apr 2008
Posts: 2
Thank you. I also found that this did the trick for me.

awk '/ALTER/,/;/' zpdm1_tab.sql > zpdm1_con.sql

Thanks for your reply.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0