3 ms·
Maybe use awk? $ echo '<td>2017-01-09 <b>08:30</b></td>' | awk -F'[<>]' '{print $5}' This will give you '08:30'. Unicode seems to be also supported: $ ec
by protomikron 10y ago
Maybe use awk?
$ echo '<td>2017-01-09 <b>08:30</b></td>' | awk -F'[<>]' '{print $5}'
This will give you '08:30'. Unicode seems to be also supported:
$ echo 'λf. (λx. f (x x)) (λx. f (x x))' | awk -F'[λ.]' '{print $4}'
This prints 'x'. For clarity some other matches:
$1: ''
$2: 'f'
$3: ' ('
$4: 'x'
...
- peterburkimsher 10y agoFine, until the next row doesn't have <b></b> tags. So the $5 no longer matches where it should. I'm just suggesting easier syntax, and a custom tool. Like dd is for disk copying, instead of cp/gzip/etc. A simple tool that will just work. This is the syntax I'm going for: textBetween("<td>", "</td>") | replace ("<b>", "") | replace ("</b>", "") Maybe with some magic strings, e.g. textBetween(":", "end")
- protomikron 10y agoYeah you are right, but if the input is more sophisticated I would probably use a scripting language and its full-fledged XML parser. Your replace part is already covered by sed (although I agree with you that the escaping can be awkward).