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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help in sed command (adding a blank line btw each block generated by pattern) frozensmilz Shell Programming and Scripting 2 01-08-2009 12:12 AM
sed: delete regex line and next line if blank one71 Shell Programming and Scripting 2 09-18-2008 06:53 AM
Match a specific IP range sylaan Shell Programming and Scripting 5 07-16-2008 07:42 AM
Adding blank white sapce at specific column Jae Shell Programming and Scripting 6 08-08-2007 09:20 AM
adding blank line in egrep antalexi UNIX for Dummies Questions & Answers 2 05-24-2004 01:40 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-09-2009
danmauer danmauer is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 42
SED - adding blank line after each Range Match

the following range matching works great but i wish to add a blank line after each range result set... which i've tried and researched to no avail

MY INPUT DATA:

Quote:
typeset lfile_selection_count=${1}
typeset lcyclename_suffix=_cycle${lfile_selection_count}

cat > ${Vsqlfile} <<BATCH_EOF
-- THESE OPTION SETTINGS MAKE SURE THAT THE SQL IS PROCESSED
-- CORRECTLY WITHIN THE CONTEXT OF THIS SCRIPT. SPECIFICALLY,
-- THE SCRIPT WILL STOP AND ISSUE AN ERRROR MESSAGE ON THE FIRST
-- SQL STATEMENT THAT RETURNS A NON-ZERO CONDITION CODE (-S ON).
-- THE SCRIPT WILL NOT COMMIT ANY CHANGES UNTIL THE COMMIT
-- STATEMENT IS EXECUTED AT THE END OF THE SCRIPT (I.E. -C AUTOCOMMIT
-- IS OFF). tHE PROMPT IS TURNED OFF SO THAT IT IS NOT SHOWN
-- IN THE OUTPUT.
CONNECT TO ${Gdb2instance_ar} user ${Gdb2user} using XXXXXXXX;
UPDATE COMMAND OPTIONS USING p OFF;
UPDATE COMMAND OPTIONS USING s ON;
LIST COMMAND OPTIONS;
alter table ${Gmdsschema}.PLN_RV_SM activate not logged initially;
INSERT into ${Gmdsschema}.PLN_RV_SM
SELECT
a11.CLNDR_MTH_ID,
a11.CMPNY_GRP_CD,
a12.CRPRT_ST_CD,
a11.FNCTN_CD,
a11.PLCY_RV_CTGRY_CD,
'RQ',
a11.PLN_CRNT_YR_CN
FROM
${Gmdsschema}.PLN_RV_SM a11
join ${Gmdsschema}.CRPRT_ST a12
on (a11.CRPRT_ST_CD = a12.CRPRT_ST_CD)
WHERE a11.cmpny_grp_cd in ('GE/GG')
AND a11.TRNCTN_TYP_CD = 'TI'
;
alter table ${Gmdsschema}.PLN_RV_SM activate not logged initially;
INSERT into ${Gmdsschema}.PLN_RV_SM
select a11.CLNDR_MTH_ID,
a11.CMPNY_GRP_CD,
a12.CRPRT_ST_CD,
a11.FNCTN_CD,
a11.PLCY_RV_CTGRY_CD,
'RQ',
a11.PLN_CRNT_YR_CN
FROM
${Gmdsschema}.PLN_RV_SM a11
join ${Gmdsschema}.CRPRT_ST a12
on (a11.CRPRT_ST_CD = a12.CRPRT_ST_CD)
WHERE a11.cmpny_grp_cd in ('GI')
AND a11.TRNCTN_TYP_CD = 'TI'
;


CURRENT CODE I'M USING:


Code:
 
sed -n '/[Ss][Ee][Ll][Ee][Cc][Tt][ ]*$/,/;/p' $INPUT_FILE

RESULTS I'M GETTING:

Quote:
SELECT
a11.CLNDR_MTH_ID,
a11.CMPNY_GRP_CD,
a12.CRPRT_ST_CD,
a11.FNCTN_CD,
a11.PLCY_RV_CTGRY_CD,
'RQ',
a11.PLN_CRNT_YR_CN
FROM
${Gmdsschema}.PLN_RV_SM a11
join ${Gmdsschema}.CRPRT_ST a12
on (a11.CRPRT_ST_CD = a12.CRPRT_ST_CD)
WHERE a11.cmpny_grp_cd in ('GE/GG')
AND a11.TRNCTN_TYP_CD = 'TI'
;
select
a11.CLNDR_MTH_ID,
a11.CMPNY_GRP_CD,
a12.CRPRT_ST_CD,
a11.FNCTN_CD,
a11.PLCY_RV_CTGRY_CD,
'RQ',
a11.PLN_CRNT_YR_CN
FROM
${Gmdsschema}.PLN_RV_SM a11
join ${Gmdsschema}.CRPRT_ST a12
on (a11.CRPRT_ST_CD = a12.CRPRT_ST_CD)
WHERE a11.cmpny_grp_cd in ('GI')
AND a11.TRNCTN_TYP_CD = 'TI'
;

RESULT I looking to get: (see blank line after semicolumn)

Quote:
SELECT
a11.CLNDR_MTH_ID,
a11.CMPNY_GRP_CD,
a12.CRPRT_ST_CD,
a11.FNCTN_CD,
a11.PLCY_RV_CTGRY_CD,
'RQ',
a11.PLN_CRNT_YR_CN
FROM
${Gmdsschema}.PLN_RV_SM a11
join ${Gmdsschema}.CRPRT_ST a12
on (a11.CRPRT_ST_CD = a12.CRPRT_ST_CD)
WHERE a11.cmpny_grp_cd in ('GE/GG')
AND a11.TRNCTN_TYP_CD = 'TI'
;

select
a11.CLNDR_MTH_ID,
a11.CMPNY_GRP_CD,
a12.CRPRT_ST_CD,
a11.FNCTN_CD,
a11.PLCY_RV_CTGRY_CD,
'RQ',
a11.PLN_CRNT_YR_CN
FROM
${Gmdsschema}.PLN_RV_SM a11
join ${Gmdsschema}.CRPRT_ST a12
on (a11.CRPRT_ST_CD = a12.CRPRT_ST_CD)
WHERE a11.cmpny_grp_cd in ('GI')
AND a11.TRNCTN_TYP_CD = 'TI'
;

I thank you in advance for your time.

-----Post Update-----

I found solution at:

Need help in sed command (adding a blank line btw each block generated by pattern)

Sorry for the trouble... didn't see that post until it came up as "helpfull thread" to my new post :-(

Last edited by danmauer; 06-10-2009 at 01:05 PM..
 

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 08:49 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