I seem to be to stupid to parse some HTML Files with Bash. We have some files which have lines like:
var A4_total = 2018 + 4730;
var Other1_total = 3242 + 3828;
(They tell us how many pages the Printers have printed). I need to calculate the first two Values together (2018 and 3242). My Approach is:
hilfsvar1=$(echo `grep -F var\ A4_total StatCntMedia.htm | sed 's/var\ A4\_total\ \=\ //g'` | sed -ne "s/^[^=]\++//p" | sed 's/;//g'); hilfsvar2=$(echo `grep -F var\ Other1_total StatCntMedia.htm | sed 's/var\ Other1\_total\ \=\ //g'` | sed -ne "s/^[^=]\++//p" | sed 's/;//g'); echo "$hilfsvar1 + $hilfsvar2" | bc
This will fail. The two variables do have the right content:
[User]# echo $hilfsvar1
4730
[User]# echo $hilfsvar2
3828
But this is where I can't get forward:
[User]# echo "$hilfsvar1 + $hilfsvar2"
+ 3828
(Sorry for my scripting, I don't have deeper knowlede of Script languages :) ) - I would be happy to resolve this in another way if someone does have a solution.
Thanks in advance, Jonas
to stupid
, it'stoo stupid
:-).