The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 05-24-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 717
Hi.

I think that grep will not cross newlines, so that you would need to place your commands each on a single line. There is a note in my man grep page about using perl regular expressions, but that it is undocumented. The awk and perl scripts can make use of settable record boundaries.

Here's a perl quickie:

Code:
#!/bin/sh

# @(#) s1       Demonstrate perl quickie for unmatched string across lines.

FILE=${1-data1}

perl -wn -e 'BEGIN{$/=";"} print if not /tablespace/' $FILE

exit 0

And running this on your sample contained in file data1:

Code:
% ./s1

create table third
(
  BBL_CUSTOMER_NAME      VARCHAR2(32),
);
create table
forth
(
  BBL_CUSTOMER_NAME      VARCHAR2(32) );

Best wishes ... cheers, drl