1
I would like to delete all lines that have the string Excluído
, searching from one specific string to the end of another. Example:
<p class="FolderPath">
<table class="DiffTable">
<tr>
<td class="DiffName">
<a name="I36676">
</a>
</td>
<td>
Excluído no destino
</td>
</tr>
</table>
</p>
Delete all lines in the middle of the string Excluído
starting the search for the string from <p class="FolderPath">
up to the string </p>
. I know how to delete the line containing the string:
sed '/Excluído/d' arquivo.txt
What it would be like to erase
N
lines ? starting from<p class="FolderPath">
up to the string</p>
?
I used the command
sed -n '/DiffTable/,/<\/p>/p' arquivo.html |grep -q Excluído && sed '/"DiffTable"/,/<\/p>/{//d}' arquivo.html || echo "Palavra buscada nao existe"
without the exclamation in d , he returned to me without the<table class="DiffTable">
and without the</p>
but did not delete the other lines– Rakiz
Whoa, the replacement part was like this?
sed '/"DiffTable"/,/<\/p>/d' arquivo.html
Here is working as I understood you wanted, delete all lines between these tags if there is the word Deleted. Let me know if it works,– MrPaper
ah yes, the problem was in d , it worked now!
– Rakiz
@Mrpaper, if you have in the file two paragraphs with tables, one with "Deleted" and the other without, your program will delete both! It seems to me that what is requested is that only the paragraphs containing "excluded".
– JJoao
Opa, Jjoão, truth. If there are two identical tags, one with the string searched and the other without, will delete both. If his file has repetitions of the searched tags, it will not work.
– MrPaper
I did the test with more than one tag as Jjoão said, really it excludes both. How to proceed?
– Rakiz