我想删除空格并连接以上一行末尾的特定单词开头的行。
示例来自
`<b>any thing that matters<b> what ever, i don't know.
<font=any type> what ever you do is not right<font>
<br>this line will go to the end of above line
<Hi>not this one<hi>
<br>but this one
<go>i hope you understand<go>`
到
`<b>any thing that matters<b> what ever, i don't know.
<font=any type> what ever you do is not right<font><br>this line will go to the end of above line
<Hi>not this one<hi><br>but this one
<go>i hope you understand<go>`
由于文件量很大,我想借助命令来完成。谢谢。
答案1
如果它只是一个长文件,您可以使用 LibreOffice 打开它并使用正则表达式进行搜索和替换。
https://help.libreoffice.org/Common/List_of_Regular_Expressions
答案2
您可以使用 sed 单行命令“40. 如果一行以等号开头,则将其追加到前一行”的变体http://www.catonmat.net/blog/sed-one-liners-explained-part-one/,将“=”替换为您想要连接的任何字符,例如在空格后跟“<br>”进行连接,例如
$ sed -e :a -e '$!N;s/\n[[:space:]]*<br>/<br>/;ta' -e 'P;D' <yourfile>
应该管用