Get characters between two words


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get characters between two words
# 1  
Old 04-17-2011
Get characters between two words

Guys,

Here is the txt file...

Code:
SLIC  N0SLU704034789    rŒ° EJ00     ó<NL     DMRG>11 100 4B                                                          2
SLIC  N0SLU704034789    rΡ TJ10      <4000><NL>                                                                      2
SLIC  N0SLU704034789    rΡ TJ10      <7001> 34 789 704                                                               2
SLIC  N0SLU704034789    rΡ TJ10      <HJS1>                                                                          2
SLIC  N0SLU704034789    rΡ TJ10     <<HJS2>                                                                          2
SLIC  N0SLU704034789    rΡ TJ10     *<HJS3>                                                                          2
SLIC  N0SLU704034789    rΡ TJ10     %<HJS4>                                                                          2
SLIC  N0SLU704034789    rΡ TJ10     @<HJS5>                                                                          2
SLIC  N0SLU704034789    rŒ° TJ10     ó<HJS6>                                                                          2
SLIC  N0SLU704034789    rŒ° TJ10     Î<9134>                                                                          2
SLIC  N0SLU704034789    rΡ TJ10      <6011> 60<NL>   61<NL>   62<NL>   63<NL>   64<BL>   65<NL>   66<NL>             2
SLIC  N0SLU704034789    rΡ TJ10             67<NL>   68<NL>   69<BL>   70<NL>   71<NL>   72<NL>   73<NL>             2
SLIC  N0SLU704034789    rΡ TJ10             74<BL>   75<NL>   76<NL>   77<NL>   78<NL>   79<BL>   80<NL>             2
SLIC  N0SLU704034789    rΡ TJ10             81<NL>   82<NL>   83<NL>   84<BL>   85<NL>   86<NL>   87<NL>             2
SLIC  N0SLU704034789    rΡ TJ10     <       88<NL>   89<BL>   90<NL>   91<NL>   92<NL>   93<NL>   94<BL>             2
SLIC  N0SLU704034789    rΡ TJ10     *<6012>     0.61833<NL> 0.67083<NL> 0.72917<NL> 0.78917<NL> 0.85333<BL> 0.92500  2
SLIC  N0SLU704034789    rΡ TJ10     %<NL> 1.00417<NL> 1.09083<NL> 1.18833<NL> 1.29500<BL> 1.41250<NL> 1.54750        2
SLIC  N0SLU704034789    rΡ TJ10     @<NL> 1.69917<NL> 1.86417<NL> 2.04583<BL> 2.24750<NL> 2.46833<NL> 2.71333        2
SLIC  N0SLU704034789    rŒ° TJ10     ó<NL> 2.98417<NL> 3.27750<BL> 3.60583<NL> 4.05500<NL> 4.56333<NL> 5.07333        2
SLIC  N0SLU704034789    rŒ° TJ10     Î<NL> 5.64000<BL> 6.28250<NL> 6.86917<NL> 7.76000<NL> 8.70000<NL> 9.71250        2
SLIC  N0SLU704034789    rΡ TJ10      <BL>10.65667<NL>11.13833<NL>12.09250<NL>13.52667<NL>15.37167                    2
SLIC  N0SLU704034789    rΡ TJ10      <7005> 95<NL>   96<NL>   97<NL>   98<NL>   99<BL>  100<NL>  101<NL>             2
SLIC  N0SLU704034789    rΡ TJ10            102<NL>  103<NL>  104<BL>  105<NL>  106<NL>  107<NL>  108<NL>             2
SLIC  N0SLU704034789    rΡ TJ10            109<BL>  110<NL>  111<NL>  112<NL>  113<NL>  114<BL>  115<NL>             2
SLIC  N0SLU704034789    rΡ TJ10     <      116<NL>  117<NL>  118<NL>  119<BL>  120<NL>                               2
SLIC  N0SLU704034789    rΡ TJ10     *      121 AND<NL>                                                               2
SLIC  N0SLU704034789    rΡ TJ10     %      OVER                                                                      2
SLIC  N0SLU704034789    rΡ TJ10     @<7006>    17.70167<NL>19.97333<NL>22.37333<NL>22.79083<NL>24.20333<BL>26.49417  2
SLIC  N0SLU704034789    rŒ° TJ10     ó<NL>29.00250<NL>31.88750<NL>35.14250<NL>38.87250<BL>43.09167<NL>47.64083        2
SLIC  N0SLU704034789    rŒ° TJ10     Î<NL>52.56333<NL>57.81583<NL>63.65167<BL>70.06583<NL>76.72500<NL>83.33250        2
SLIC  N0SLU704034789    rΡ TJ10      <NL>83.33250<NL>83.33250<BL>83.33250<NL>83.33250<NL>83.33250<NL>83.33250        2
SLIC  N0SLU704034789    rΡ TJ10      <NL>83.33250<BL>83.33250<BL> 0.00000                                            2
SLIC  N0SLU704034789    rΡ TJ10      <NL     DMRG>11 100 4 1                                                         2
SLIC  N0SLU704034789    rΡ EJ10      <4000>BRIEF                                                                     2

I want to read all the characters between <7001> 34 789 704 and DMRG> and write in file something like as shown below, so that i could form a XML with these values.

60
0.61833
61
0.67083

Please help me...I am struck

or

Last edited by gowrishankar05; 04-17-2011 at 08:03 PM.. Reason: Just made bold
# 2  
Old 04-17-2011
What exactly are you trying to extract and combine there?
What fields? Rules, patterns?
# 3  
Old 04-17-2011
Hi,

If you see copy mark 6011 there are few values like 60, 61, 62 and its corresponding values are in copy mark 6012.

So I need to map 60 against 0.61833 and so on...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to extract characters between two search words in a script!!

Hi, I have a log file which is the output from a xml script : <?xml version="1.0" ?> <!DOCTYPE svc_result SYSTEM "MLP_SVC_RESULT_320.DTD"> <svc_result ver="3.2.0"> <slia ver="3.0.0"> <pos> <msid type="MSISDN" enc="ASC">8093078040</msid> <poserr> ... (4 Replies)
Discussion started by: arjunstarz
4 Replies

2. Shell Programming and Scripting

Perl: Pattern to remove words with less than 2 characters.

Hello. I've been thinking about how to go about this. I know I'm close but still does not work. I need to remove any word in that is not at least 2 characters long. I've removed all the non-alphabetic characters already (numbers included). Here's an example: my $string = "This string is a... (4 Replies)
Discussion started by: D2K
4 Replies

3. UNIX for Dummies Questions & Answers

deleting words in list with more than 2 identical adjacent characters

Morning Guys & Gals, I am trying to figure out a way to remove lines from a file that have more than 2 identical characters in sequence.. So if for instance the list would look like ; the output would be ; I can't seem to get my head around perl (among many other... (7 Replies)
Discussion started by: TAPE
7 Replies

4. Shell Programming and Scripting

Merging words splitted into characters with awk

I have an OCR output with some words splitted into single characters separated by blank spaces, and I want the same text with these words written correctly. Example: This is a text w i t h some s p l i t e d W o r d s . The regular expression for matching splitted words could be something... (5 Replies)
Discussion started by: dokamo
5 Replies

5. Shell Programming and Scripting

Replace words with the first characters

Hello folks, I have a simple request but I can't find a simple solution. Hare is my problem. I have some dates, I need to replace months with only the first 3 characters (jan for january, feb for february, ... all in lower case) ~$ echo '3 october 2010' | sed 3 oct 2010I thought of something... (8 Replies)
Discussion started by: tukuyomi
8 Replies

6. UNIX for Dummies Questions & Answers

Vim help - delete words in a file or characters after pattern

I have a file with words that begin with character #. Whenver that character is found that word should be deleted throughout the file. How do I do that in VIM. e.g: afkajfa ladfa ljafa #222222 kjafad ljl afajkj kjlj uouu #44444 jlkj lkjl Output should be afkajfa ladfa ljafa kjafad... (1 Reply)
Discussion started by: osbourneric
1 Replies

7. Programming

Counting characters, words, spaces, punctuations, etc.

I am very new to C programming. How could I write a C program that could count the characters, words, spaces, and punctuations in a text file? Any help will be really appreciated. I am doing this as part of my C learning exercise. Thanks, Ajay (4 Replies)
Discussion started by: ajay41aj
4 Replies

8. Shell Programming and Scripting

deleting symbols and characters between two words

Hi Please tell me how could i delete symbols, whitespaces, characters, words everything between two words in a line. Let my file is aaa BB ccc ddd eee FF kkk xxx 123456 BB 44^& iop FF 999 xxx uuu rrr BB hhh nnn FF 000 I want to delete everything comes in between BB and FF( deletion... (3 Replies)
Discussion started by: rish_max
3 Replies

9. Shell Programming and Scripting

Script for pulling words of 4 to 7 characters from a file

Even just advice on where to start would be helpful. Thank You (2 Replies)
Discussion started by: Azeus
2 Replies

10. Shell Programming and Scripting

Display text between two words/characters

Using sed or awk, I need to display text between two words/characters. Below are two example inputs and the desired output. In a nutshell, I need the date-range value between the quotes (but only the first occurance of date-range as there can be more than one). Example One Input: xml-report... (1 Reply)
Discussion started by: cmichaelson
1 Replies
Login or Register to Ask a Question