How to parse a specifc value between html tags using sed?


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 03-13-2018
How to parse a specifc value between html tags using sed?

Hi,

im trying to read a Temperature value from html code.

So far i have managed to reduce the whole html page down to this single line with the following sed command:
Code:
sed -n '/Temperature/p' $temp_temperature | tee temp_string
<TD width='350'>Temperature :</td><td>25 &deg;C</td></tr></table><TABLE width= "100%" border="0" cellpadding='5' cellspacing="0">

Now the problem is how to get the value "25" out from that line im left with. There are 2 <td> tags in this line of html and i cannot figure out the sed expression to save that "25" into a variable that i can use with the rest of my bash script.

Heres one of the examples that didnt work for me:
Code:
sed 's/><td\(.*[^<>]\+\?>\)\(.*\)&deg/\2/g' sed_test.txt

Can anyone help me out with this?
# 2  
Old 03-13-2018
you were almost there:
Code:
sed 's/.*><td\(.*[^<>]\+\?>\)\(.*\)\&deg.*/\2/g' sed_test.txt

OR
Code:
sed 's/.*>\([0-9][0-9]*\).*\&.*/\1/' sed_test.txt

This User Gave Thanks to vgersh99 For This Post:
naittis (03-13-2018)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Replace HTML tags using sed regex Badhrish Shell Programming and Scripting 3 02-20-2015 10:17 AM
Parse html cmccabe Shell Programming and Scripting 5 02-08-2015 03:24 PM
Parse multiple html files in directory cmccabe Shell Programming and Scripting 15 12-18-2014 05:33 PM
awk to parse html file cmccabe Shell Programming and Scripting 4 09-29-2014 05:08 PM
Replacing HTML tags with sed twjolson UNIX for Dummies Questions & Answers 5 09-12-2013 03:20 PM
help with sed needed to extract content from html tags seb001 Shell Programming and Scripting 9 03-06-2012 07:44 AM
sed command for copying the contents of other file replacing it another file on specifc pattern balrajg Shell Programming and Scripting 0 01-26-2011 10:42 PM
sed to parse html prasanna1157 Shell Programming and Scripting 11 10-19-2010 03:37 AM
sed - striping out html tags bigtonydallas Shell Programming and Scripting 4 12-30-2009 07:02 AM
Parse HTML tag parameters and text senszey Shell Programming and Scripting 1 12-13-2009 02:56 PM
How to use sed to remove html tags including text between them alphagon Shell Programming and Scripting 2 11-17-2008 07:05 PM
Replace space, that is not in html tags <> with new line using sed matt1311 Shell Programming and Scripting 5 07-27-2008 08:39 PM
Problem with 'sed' command while using HTML tags The Observer Shell Programming and Scripting 5 06-09-2008 11:00 AM
How to supplement HTML tags with SED DocBrewer Shell Programming and Scripting 3 04-25-2008 10:40 AM
unsing sed to strip html tags - help zap Shell Programming and Scripting 3 04-18-2004 05:03 AM