I have this syntax in a file (http response times from analog):
<thead><tr><th class="x">seconds</th><th class="R">reqs</th><th class="r">%reqs</th><th class="B">Gbytes</th><th class="b">%bytes</th></tr></thead>
<tbody><tr><td class="x">0</td><td class="R">10927</td><td class="r"> 0.47%</td><td class="B">0.01</td><td class="b"> 0.18%</td></tr>
<tr><td class="x"><= 0.01</td><td class="R">1026471</td><td class="r">44.59%</td><td class="B">0.11</td><td class="b"> 1.81%</td></tr>
<tr><td class="x">0.01-0.02</td><td class="R">535390</td><td class="r">23.26%</td><td class="B">0.06</td><td class="b"> 0.95%</td></tr>
<tr><td class="x">0.02-0.05</td><td class="R">93298</td><td class="r"> 4.05%</td><td class="B">0.27</td><td class="b"> 4.29%</td></tr>
etc.
What I want to be left with is the value for seconds - so 2 characters after "x" and before the first <
And also the request length, so 2 characters after "R" and before the next subsequent <
Probably not the best exercise to get to grips with regex but that's what I'm stuck with. Any help would be incredibly useful.
Expected result:
seconds reqs
0 10927
<= 0.01 1026471
0.01-0.02 535390
0.02-0.05 93298
sed 's/.*"x".\([^<]*\).*"R".\([^<]*\).*/\1\t\2/' file
Note that I posted this for your education only. Better do not use such solution.