having the following file:
<tr class="in">
<th scope="row">In</th>
<td>1.2 kB/s (0.0%)</td>
<td>8.3 kB/s (0.0%) </td>
<td>3.2 kB/s (0.0%) </td>
</tr>
<tr class="out">
<th scope="row">Out</th>
<td>6.7 kB/s (0.6%) </td>
<td>4.2 kB/s (0.1%) </td>
<td>1.5 kB/s (0.6%) </td>
</tr>
I want to get the values between each second <td></td>
(and save it to a file) like this:
8.3
4.2
My code so far:
# get the lines with <td> tags
cat tmp.txt | grep '<td>[0-9]*.[0-9]' > tmp2.txt
# delete whitespaces
sed -i 's/[\t ]//g' tmp2.txt
# remove <td> tag
cat tmp2.txt | sed "s/<td>//g" > tmp3.txt
# remove "kB/s (0.0%)"
cat tmp3.txt | sed "s/kB\/s\((.*)\)//g" > tmp4.txt
# remove </td> tag and save to traffic.txt
cat tmp4.txt | sed "s/<\/td>//g" > traffic.txt
#rm -R -f tmp*
How can I do this the common way? This code is really noobish..
Thanks in Advance, Marley