Display text between two words/characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Display text between two words/characters
# 1  
Old 11-25-2008
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 <test title="ABC" date-range="1070101" table="test" />

Desired Output: 1070101

Example Input Two:
xml-report <test title="ABC" something="here" date-range="106010172" table="test"/><subtest title="123" date-range="1080101"/>

Desired output: 106010172 (e.g. the first date-range occurance)

I've tried numerous awk/sed command and came close. I'm running CentOS 4.4 with sed --version = 4.1.2 and awk --version = 3.1.3.

Thanks,
Cam
# 2  
Old 11-25-2008
Use search... The same question was asked yesterday.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Display multiple words into a single td tag

awk 'BEGIN{print "<table>"} {print "<tr>"; for ( i=1;i<NF;i++) print " <td>" $I "</td>"; print "</tr>"} END{print " </table>"}' <file name > (6 Replies)
Discussion started by: Himanshu1
6 Replies

2. Shell Programming and Scripting

display unique words.

I am having a file with duplicate words how can I eliminate them ant,bat bat,cat cat a.txt | grep -bat | awk '{print $1}' expecting o/p as ant,bat,cat How can I display the output as ant,bat,cat in a single line and no duplicates exists. (2 Replies)
Discussion started by: shikshavarma
2 Replies

3. UNIX for Dummies Questions & Answers

Display all the words whose length is equal to the longest word in the text

Hi Guys, I was going some trial and error to see if I can find the longest word in a text. I was using Pipes because they are easier to use in this case. I was stuck on this for a while so I thought I'll get some help with it. I tried this code to separate all the words in a text in... (4 Replies)
Discussion started by: bawse.c
4 Replies

4. UNIX Desktop Questions & Answers

Display a specific words from a multiple lines

well, i am so not familiar with this kind of things but i am gonna explain extactly what i am looking for so hopfully someone can figure it out :) i have a command that shows memory usage besides the process name, for example(the command output): 500 kb process_1 600 kb process_2 700 kb... (4 Replies)
Discussion started by: Portabello
4 Replies

5. Shell Programming and Scripting

Get characters between two words

Guys, Here is the txt file... SLIC N0SLU704034789 rŒ° EJ00 ó<NL DMRG>11 100 4B 2 SLIC N0SLU704034789 rŒ° TJ10 <4000><NL> 2 SLIC N0SLU704034789 ... (2 Replies)
Discussion started by: gowrishankar05
2 Replies

6. 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

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

Display most top 10 occurring words along with number of ocurences of word inthe text

I need Display the most top 10 occurring words along with the number of occurences of those words in the given text. Sample text as below: "The Travails of Single South Indian men of conservative upbringing" or "Why we don't get any..." Yet another action packed weekend in Mumbai, full of... (2 Replies)
Discussion started by: smacherla
2 Replies

10. Programming

how i display number in words

helo i want to implement the following concept in my project write a c/c++ algorithm for : accept a number from the user not greater than 6 digits and display the number in words i.e. if the input from the user is 18265 then the output should be Eighteen Thousand Two Hundred Sixty Five. if the... (3 Replies)
Discussion started by: amitpansuria
3 Replies
Login or Register to Ask a Question