linux - sed:用空格替换 <p> </p> 中的换行符

标签 linux shell sed

假设我有文件:index.html

index.html

<p class="p">This
entry will determine the number of transmit threads, each channel
represents one thread, which can handle multiple multicast ports.
All channels are enabled by default. To temporarily disable a particular
channel, use the folowing configuration lines:</p>

如何仅在

标记内将换行符替换为空格

例如,将index.html更改为:

<p class="p">This entry will determine the number of transmit threads, each channel represents one thread, which can handle multiple multicast ports. All channels are enabled by default. To temporarily disable a particular channel, use the folowing configuration lines:</p>`

尝试过,

sed -e "/<p>/s/\n/ /g" index.html

不工作

最佳答案

使用gnu-sed:

sed -E '/<p class="p">/{:a; N; s/\n/ /g; /<\/p>/!ba;}' index.html

关于linux - sed:用空格替换 <p> </p> 中的换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74859884/

相关文章:

sed - 使用 Sed 删除多行

linux - python函数用于山谷升序降序

linux - 意外的 token 错误 :awk when ran with sh var

regex - 在 Linux 命令行上使用正则表达式查找文件夹后的文件

linux - Shell - 如何从具有多种模式的文本文件中删除行?

python - 如何根据条件将 csv 文件合并到单个文件并将文件名添加为列?

bash - 捕获第 n 场 bash

linux - 在 Linux 中阻止 USB HID

linux - 在bash中为postgresql生成随 secret 码

unix - 寻找一种更有效(和可移植)的方式来在 unix 中获取(数字)文件权限