Computing.Net > Forums > Programming > Deleting a block of text with sed

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Deleting a block of text with sed

Reply to Message Icon

Name: rojanu
Date: July 24, 2008 at 00:23:29 Pacific
OS: Windows XP SP2
CPU/Ram: intel p4 1024 Mb ram
Comment:


Hi everyone,

I have a text with blocks similar following
[FILE]
<tu origin="tbx" tuid="32316" vuid="32316" filename="/some/path/to/a/file" SwKey="SomeStringIncluding_-:&$" xml:space="preserve" Inst="1" filetype=".txt">
<tuv xml:lang="EN-US">
<seg>Hide Process &Tool Tips</seg>
</tuv>
<tuv xml:lang="DE-DE">
<seg>&QuickInfo ausblenden</seg>
</tuv>
</tu>
[/FILE]
and I would like to remove blocks with text matching e.g. "SomeStringIncluding_-:&$" and keep rest of the file

I have found another post and tried to adapt the code to my file but as there is no explanation to the code I am struggling, here is the sed script I am using
[SED_CODE]
s/>/\>/g
s/</\</g
/^\s*$/d
/^\s*\<\/tu\>/G
/./{H;;}
x;/SomeStringIncluding_-:\&\$/d;
s/\>/>/g
s/\</</g
/^$/d
[/SED_CODE]

I will be glad if you have time to explain the code as well, so next time I can stand on my own feet

Thanks in advance




Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: July 24, 2008 at 04:27:06 Pacific
Reply:

use awk


awk 'BEGIN{RS="[[]/FILE[]]"}/SomeString/{printf "%s", $0;print RT}' file


0

Response Number 2
Name: rojanu
Date: July 25, 2008 at 04:00:38 Pacific
Reply:

I am not sure that I understand,
When I run that command the output was the same as input


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Ping on DOS 6.22 ksh to windows



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Deleting a block of text with sed

Capturing/Filtering Blocks of Text: www.computing.net/answers/programming/capturingfiltering-blocks-of-text/16275.html

Delete first line of text www.computing.net/answers/programming/delete-first-line-of-text/13312.html

editing a txt file using cdm www.computing.net/answers/programming/editing-a-txt-file-using-cdm-/18589.html