lucasschvantes
(usa CentOS)
Enviado em 12/03/2019 - 12:05h
Olá pessoal,
Tenho um shell script que vai alterar e inserir valores em um texto pronto.
Texto:
<h2> Teste </h2>
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
<h2> Teste </h2>
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
<h2> Teste </h2>
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
<h2>Teste </h2>
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Eu preciso alterar o segundo ou terceiro, as vezes o quarto <h2> que aparece no texto. Achei como alterar a primeira e a última ocorrência no texto, mas não uma determinada.
Na linha usamos
sed 's/<h2>/Teste<h2>/2' texto.txt onde o 2 aponta a segunda ocorrência em todas as linhas.
Os textos variam os números de linha, sendo assim não consigo pegar determinada linha.
A minha dúvida é, tem como alterar a segunda ou terceira ocorrência no texto?
Fico grato pela ajuda.