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
Search between pattrens with one string in one or other line........ pbsrinivas Shell Programming and Scripting 12 07-02-2007 03:37 AM
Search and insert between Pattrens... pbsrinivas Shell Programming and Scripting 7 06-11-2007 04:25 AM
How to count lines - ignoring blank lines and commented lines kthatch UNIX for Dummies Questions & Answers 6 05-25-2007 02:21 AM
Search between pattrens. pbsrinivas Shell Programming and Scripting 3 05-08-2007 05:34 PM
Sed insert and Change lines help needed JunkYardWars Shell Programming and Scripting 2 03-24-2006 05:50 AM

 
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 03-21-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
Need to change a set of lines between two given Pattrens

Hi All

I have a Small Requiement

I wanted to replace all the Follwing lines as follows

Input:: file1

EVALUATE WS-TEMP-ATTR(15:1)
WHEN 'D'
MOVE DFHDARK TO WS-ATTR-COLOR
WHEN OTHER
MOVE DFHDFT TO WS-ATTR-COLOR
END-EVALUATE.

Output::file2

TCSCMT* EVALUATE WS-TEMP-ATTR(5:1)
TCSCMT* WHEN 'D'
TCSCMT* MOVE DFHDARK TO WS-ATTR-COLOR
TCSCMT* WHEN OTHER
TCSCMT* MOVE DFHDFT TO WS-ATTR-COLOR
TCSCMT* END-EVALUATE.



I have Tried Some thing of this sort with sed

sedscript File

/ EVALUATE WS-TEMP-ATTR(5:1)/c\
TCSCMT* EVALUATE WS-TEMP-ATTR(5:1)
/ WHEN 'D'/c\
TCSCMT* WHEN 'D'
/ MOVE DFHDFT TO WS-ATTR-COLOR/c\
TCSCMT* MOVE DFHDFT TO WS-ATTR-COLOR
/ WHEN 'OTHER'/c\
TCSCMT* WHEN 'OTHER'
/ MOVE DFHDFT TO WS-ATTR-COLOR/c\
TCSCMT* MOVE DFHDFT TO WS-ATTR-COLOR
/ END-EVALUATE./c\
TCSCMT* END-EVALUATE.


sed -f sedscript file1 > file2

I have got what i wanted but.......

If i have more than one END-EVALUATE in the file1 the it is replacing everything

But i want it to happen only between these two line
1 EVALUATE WS-TEMP-ATTR(5:1)
2 END-EVALUATE

So thats it doesn't Effecft others


This is basically to comment the Paticular set of lines in the code...
 

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:42 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