Answer the question
In order to leave comments, you need to log in
How to output in one line?
There is a table:
<table class="searchDetails">
<tr>
<th>Автор:
</th>
<td><span class="hl_none">Ф. И. О.</span>
</td>
</tr>
<tr>
<th>Сведения:
</th>
<td><span class="hl_none">ППП., 2011</span>
</td>
</tr>
<tr>
<th>Тематика:
</th>
<td><span class="hl_none">ООО</span>
</td>
</tr>
</table>
<div class="searchLink"></div>
И Т.Д.
#!/bin/bash
A=$(cat table.htm | sed -n -e '/<table class=\"searchDetails\">/,/<div class=\"searchLink\">/ p' | grep "<span class=\"hl_none\">" -B 2 | grep "<th>" | sed -e 's/<th>//' -e 's/ //' | tr -d '\r')
A2=$(cat table.htm | sed -n -e '/<table class=\"searchDetails\">/,/<div class=\"searchLink\">/ p' | grep "<span class=\"hl_none\">" | sed -e 's/.*<span class=\"hl_none\">//' -e 's/<\/span>//' | tr -d '\r')
B=$(paste -d " " <(echo "$A") <(echo "$A2"))
echo "$B"
Answer the question
In order to leave comments, you need to log in
With sed like this:
sed -n '/<th>\|<td>\|<\/table/p' t.html | sed 's/^\s*//' | sed ':a; N; s/\n/ /; ta;' | sed 's/ <\/table> /\n/;s/<[^>]*>//g'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question