假设我有一个文件: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>

如何将换行符替换为内的空格

tag only

For example, changing Index.html to:

<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相关问答推荐

仅使用Find搜索32字符长的目录

如何正确Forking 并完成进程以避免 EAGAIN 错误

使用来自 yocto build 而不是主机系统的 protoc

为什么 linux shell diff 命令有时会显示与空行相关的输出,即使存在 -B(--ignore-blank-lines)选项?

使用 sed 或 awk 格式化文本

RabbitMQ 安装后没有自动启动

编译过度对齐的动态分配变量时出现 icpc 错误

Eclipse 的 C# 插件

如何使目录下的所有文件在linux上可读?

使用 ssh 判断远程主机上是否存在文件

bash shell 脚本函数定义(如f () {})中使用的括号是什么?它与使用function关键字不同吗?

比较linux中两个未排序的列表,列出第二个文件中的唯一性

如何在没有空格的情况下打印 awk?

如何链接到 GCC 中特定版本的共享库

区分 Windows 和类 Unix 系统的 Makefile

如何运行我所有的 PHPUnit 测试?

ngrok 如何在防火墙后工作?

如何为 Git 命令设置自动完成功能?

env和set(在 Mac OS X 或 Linux 上)有什么区别?

如何使用mv命令移动特定目录中的文件除外?