次のファイルがあります。
<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>
次のように、各秒の間の値を取得<td></td>
してファイルに保存したい:
8.3
4.2
これまでの私のコード:
# 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*
これを一般的な方法で行うにはどうすればよいですか?このコードは本当に初心者です..
前もってありがとう、マーリー