1

TestNG generated an emailable-report.html with many Epoch time format like this:

<td rowspan="1">1444899469337</td><td rowspan="1">2316</td></tr><tr class="passedeven"><td><a href="#m1">toProjectsButton</a></td><td rowspan="1">1444899471653</td><td rowspan="1">40</td></tr><tr class="passedeven"><td><a href="#m2">toReqButton</a></td><td rowspan="1">1444899471694</td><td rowspan="1">38</td></tr><tr class="passedeven"><td><a href="#m3">toSquareButton</a></td><td rowspan="1">1444899471732</td><td rowspan="1">37</td></tr><tr class="passedeven"><td><a href="#m4">usageAmount</a></td><td rowspan="1">1444899471770</td><td rowspan="1">130</td></tr><tr class="passedeven"><td><a href="#m5">usageAppShow</a></td><td rowspan="1">1444899471900</td><td rowspan="1">2761</td></tr></tbody><tbody id="t1"><tr><th colspan="4">ÉÏ´«Ó¦ÓÃ &#8212; failed</th></tr><tr class="failedeven"><td rowspan="1">com.netease.web.ct.taskgroup.AddTask</td><td><a href="#m6">addAppTask</a></td><td rowspan="1">1444899495534</td><td rowspan="1">1212862</td>

Numbers such as 1444899469337 are Epoch time. I know I can use date command to convert a single Epoch time like this:

Execute: date -d @1447990590 +'%Y-%m-%d %H:%M:%S'
Return: 2015-11-20 11:36:30

My question is, how to use shell command to convert all the Epoch time appearances in the emailable-report.html? Does anyone have any experience on this?

Pooja S
  • 550
  • 2
  • 9
mainframer
  • 20,411
  • 12
  • 49
  • 68
  • Use XSLT and something from [this question](http://stackoverflow.com/q/3467771/258523)? – Etan Reisner Nov 25 '15 at 15:22
  • @Etan, I am sorry I made a mistake. I meant to say **emailable-report.html**, not **emailable-report.xml**. I notice the question you pointed to me is regarding `xml`, I think this is an different question. Could you unset the duplicate flag? Sorry for that. – mainframer Nov 25 '15 at 15:44
  • The solution might still be applicable depending on your html file but the general idea is the same. Use something that can parse html and then do the conversion. Don't use any non-html parsing tools (like `sed` or `awk`). – Etan Reisner Nov 25 '15 at 15:46
  • To be honest, my first thought is `sed/awk` but then I realize it is a bit hard to implement it. So I throw this issue here just in case someone else has already done this kind of thing or at least someone can recommend me some lightweight `html parser` as you said. – mainframer Nov 25 '15 at 15:53
  • I guess something like this in [How do I replace a substring by the output of a shell command with sed, awk or such?](http://stackoverflow.com/a/27823994/1983854) can help, but I cannot manage to adapt it to this case. – fedorqui Nov 25 '15 at 16:09

0 Answers0