Displaying certain text in a msg.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying certain text in a msg.
# 1  
Old 10-01-2012
Power Displaying certain text in a msg.

I have a requirement to display a part of an html response that my application gets. The response looks like this:
Code:
<html><a href='com.aprisma.spectrum.app.sd.client.SDHyperlinkHandler' sdTicketHandle='cr:419900' ocAlarmId='506618ea-f013-102d-02a7-0050569d7aa8' ticketUrl='http://lpv-casdwbdv01:8080/CAisd/pdmweb.exe?OP=SHOW_DETAIL+FACTORY=iss+PERSID=cr:419900'>Request/Incident 20056</a></html>

The part of the message I need to pull out is: "Request/Incident 20056"
where "20056" will change with every incoming message.

Is there a way to display all text between the > which is right before the R in Request and the < which is after the last digit of the number?

I have tried to do this:
Code:
SDMT=$SANM_0X12022
echo $SDMT | cut -f3 -d'>'

but my output looks like this:
Code:
Request/Incident 20056</a

I've tried everything I know.

Please helpSmilie
# 2  
Old 10-01-2012
Assumed the "Request/Incident" is always a fixed part of the msg, this should work:
Code:
awk '{TMP=substr($0,index($0,"Request/Incident")); print substr(TMP,1,index(TMP,"<")-1)}' file
Request/Incident 20056

This User Gave Thanks to RudiC For This Post:
# 3  
Old 10-01-2012
One Modification

The code that you sent worked perfectly!!! Thanks!!!

My only other question is, How would I bring JUST THE NUMBER in? So instead of the output:
Code:
Request/Incident 20085

I would like simply:
Code:
20085

MANY THANKS!@!
# 4  
Old 10-01-2012
Code:
awk '{TMP=substr($0,index($0,"Request/Incident")); print substr(TMP,18,index(TMP,"<")-18)}' file
20056

or
Code:
awk '{TMP=substr($0,index($0,"Request/Incident")+17); print substr(TMP,1,index(TMP,"<")-1)}' file

This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with text modification and displaying

I have a file storing some text and another file storing some numbers I want to display characters other than the specified place of strings one.txt xyz abc 233 skfo 4r443 sfs abc abcd sd fsdf sdfd abc 11 abc 33 abc dsaf two.txt Nt_djd_k='5-6,7-9' Nt_hh_l='3-6,7-8' a=`grep... (4 Replies)
Discussion started by: rahulsk
4 Replies

2. Shell Programming and Scripting

Displaying Formatted Text on Virtual Terminal

Hi, I'm working on a project that requires formatted text to be displayed on the screen plugged into a Linux machine. I want to be able to control this text via a bash script and format it in a particular font and size. Changing the background colour would also be beneficial. Does anyone know... (3 Replies)
Discussion started by: lcoor65
3 Replies

3. Shell Programming and Scripting

Displaying text till pattern match found in a line

Hi All, From the below line if we want to display all the text till found pattern dot/. I was trying with the below code but couldn't able to print text before the pattern. it display texts which is found after pattern. awk '/assed/{print;getline;print}' file_name | sed 's/^*. *//' input... (4 Replies)
Discussion started by: Optimus81
4 Replies

4. Shell Programming and Scripting

Finding a string and displaying the text before?

Hi folks. I am trying to script a query of a backup server that will display sessions that are "waiting" for a mount... So for, i query my system which returns a process # that is waiting... The output looks like this: 20,984 Backup Storage Pool Primary Pool T950_TAPE_WIN, Copy Pool... (3 Replies)
Discussion started by: Stephan
3 Replies

5. Shell Programming and Scripting

Displaying Result to a Text File

Hi; I am scripting in Shell and i want to write output (on screen) to a text file? ... | tee gcsw/output.txt doesnot work? :(:( (6 Replies)
Discussion started by: gc_sw
6 Replies

6. Homework & Coursework Questions

Displaying text from a MySQL table which can be modified

Hi am creating a website for my third year at uni, am trying to create a website where the client can update the content of the site themselves, i will have a news page and i want the content to be draw from my database and displayed on the front end of the site using php, i also want to have an... (1 Reply)
Discussion started by: richeyrich86
1 Replies

7. UNIX for Dummies Questions & Answers

Displaying text from a MySQL table which can be modified

Hi am creating a website for my third year at uni, am trying to create a website where the client can update the content of the site themselves, i will have a news page and i want the content to be draw from my database and displayed on the front end of the site i also want to have an admin side... (3 Replies)
Discussion started by: richeyrich86
3 Replies

8. UNIX for Dummies Questions & Answers

Displaying Text

Hi guys! I am very much new to UNIX...and I was just wondering on how you would display this text format in UNIX with only just one command : Text 1 Text 2 Text 3 Texts are in aligned vertically in such format...Thanks for your help :) (8 Replies)
Discussion started by: Knowledge_Xfer
8 Replies

9. Shell Programming and Scripting

Displaying text file in browser - perl

Don't know why this didn't get posted before but... I am having issues displaying a log file in the browser using perl and I can't get it to display at all, All i get is WHITE (blank page). I have proper permissions in my cgi-bin directory and everywhere else. So I know that's NOT the issue. ... (3 Replies)
Discussion started by: Dabheeruz
3 Replies

10. Shell Programming and Scripting

Displaying text file in browser - perl

I am having issue dispalying text file in browser using perl. Here is my code: #!/usr/bin/perl print "content-type: text/html \n\n"; open (FH , "access.log") || die "Blah $!"; while (<FH>) { print $_ ; } I have correct permissions and everything. The weired thing is when I... (1 Reply)
Discussion started by: Dabheeruz
1 Replies
Login or Register to Ask a Question