![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Deleting files that don't contain particular text strings / more than one instance of a string | kmkocot | Shell Programming and Scripting | 3 | 3 Weeks Ago 01:11 AM |
| extracting numbers from strings | gobi | Shell Programming and Scripting | 2 | 05-27-2008 12:44 AM |
| extracting a set of strings from a text file | Deanne | Shell Programming and Scripting | 2 | 09-21-2007 12:31 AM |
| Help with extracting strings from a file | cmsdelhi | Shell Programming and Scripting | 7 | 01-12-2007 09:49 AM |
| Extracting strings | hugow | UNIX for Dummies Questions & Answers | 1 | 06-24-2005 07:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Extracting text between two strings, first instance only
There are a lot of ways to extract text from between two strings, but what if those strings occur multiple times and you only want the text from the first two strings? I can't seem to find anything to work here. I'm using sed to process the text after it's extracted, so I prefer a sed answer, but whatever works is fine with me. It's an xml file, the text is between string tags (hope that doesn't cause any confusion). The text may be 1 or 100 lines long and may also contain whitespace, linebreaks, indentions, etc, which shouldn't matter much, but the location of the tags may seem fairly random in relation to the actual text and not a clean "^tagTEXTtag$". I want everything, whitespace, blank lines, etc, between the first open and close tags. Code:
<string>This is
the text
that I want
</string>
<string>text I don't want</string>
<string>more text
I don't want</string>
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|