Home Man
Search
Today's Posts
Register

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

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

Tags
bash, html, sed, solved

Login 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

The Following User Says Thank You to vgersh99 For This Useful Post:
naittis (03-13-2018)
# 3  
Old 03-13-2018
Omg it actually works! thank you
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parse html cmccabe Shell Programming and Scripting 5 02-08-2015 02:24 PM
Parse multiple html files in directory cmccabe Shell Programming and Scripting 15 12-18-2014 04:33 PM
awk to parse html file cmccabe Shell Programming and Scripting 4 09-29-2014 04:08 PM
Parse excel file with html on each cell oliveiraum Shell Programming and Scripting 6 08-20-2014 12:34 PM
Removing all except couple of html tags from html file juubuntu Shell Programming and Scripting 0 06-21-2012 08:07 AM
Extract/Parse information from html (website) TehOne Shell Programming and Scripting 5 05-02-2012 03:12 AM
Parsing HTML, get text between 2 HTML tags Mysthik Shell Programming and Scripting 1 04-14-2012 11:46 AM
sed to parse html prasanna1157 Shell Programming and Scripting 11 10-19-2010 02:37 AM
Parse HTML tag parameters and text senszey Shell Programming and Scripting 1 12-13-2009 01:56 PM
shell script to parse html file sais UNIX for Advanced & Expert Users 1 08-26-2009 11:10 AM


All times are GMT -4. The time now is 02:29 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password