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...
This working and it almost Solved my Requirement but...
IF i have some thing like
TCSCMT* MOVE OTHER TO COLOR
then is putting
TCSCMT*TCSCMT* MOVE OTHER TO COLOR
That is its PreFixing the TCSCMT* but i want the Whole line to get Replaced(basically the first 7 Chars are SPACES or ??????* for me )
So i want the 1st 7 Chars to be REPLACED by TCSCMT*
Sorry Madhan if u was not clear in what i wanted but...
The 1st 7 Chars can be any thing .... I want them to be replaced with TCSCMT*
sed -n '/EVALUATE WS-TEMP-ATTR(15:1)/,/END-EVALUATE/p' filename is getting me the Lines between EVALUATE WS-TEMP-ATTR(15:1) and END-EVALUATE
and then of all those line irrespective of what the 1st 7 Charecters or i want them to be TCSCMT*
sed '/^TCSCMT/!s/^/TCSCMT* /' i hope this Checks it its not starting with TCSCMT and then Prefixes TCSCMT* but irrespective of what the 1st 7 Charecters or i want them to be TCSCMT* Can we do that??