Name: 18dreams Date: August 8, 2005 at 06:33:34 Pacific Subject: Sed - replace block of text - but h OS: UNIX CPU/Ram: NA
Comment:
I am using a sed commmand to replace a block of text over several lines. I do this with a start string and an end string to locate the entire block of text, and replace this section with a single word. The problem I am having is that the output is in all CAPS, I just want to keep the rest of the test as is. Any thoughts? Thanks in advance.
Here is the command: sed -N -e "/^ WARNING\!/,/^IMPRESSION/!p;/Impression/p" $MOD.1 > $MOD.2
That code will not upshift or downshift any of your data, so I do not understand your issue.
The code will print (exactly as is) all lines of data that are NOT within a block of lines beginning with WARNING and ending with IMPRESSION.
It will also print all lines (exactly as is) that contain the string "Impression", which has nothing to do with the IMPRESSION keyword that terminates your defined block of lines since the case is different. If this line is not within a WARNING/IMPRESSION block, it will get printed once by the first print command and again by this second print command. If the Impression line is within a WARNING/IMPRESSION block, it will get printed only by the second print command.
So if we have this file:
line 1 line 2 Impression xxx line 3 WARNING! line 5 line 6 Impression yyy line 7 IMPRESSION line 9 line 10 Impression zzz line 11
We would get this output:
line 1 line 2 Impression xxx line 2 Impression xxx line 3 line 6 Impression yyy line 9 line 10 Impression zzz line 10 Impression zzz line 11
I am sorry, after a closer look, the data in the record is in all caps between impression and end of impression. Somehow in the late hours I couldn't see this. The rest of the record in normal. Sorry, thanks again for your time. I was driving myself crazy looking up sed commands and case.
Again, thanks alot for your help. The very first test I ran must have had normal case for some reason, but every case since has been all caps between the 2 key words.