假设我有这个文件: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
不工作
3条答案
按热度按时间vngu2lb81#
使用
gnu-sed
:wixjitnu2#
使用你展示的示例,请尝试以下
awk
代码。在记录分隔符中使用awk
的段落模式。piv4azn73#
使用sed(可能无法在所有平台上工作):
sed -i.bak 's/\n$/ /g' index.html
。请注意,sed将在此处执行更改之前备份您的文件。可以使用
tr
代替sed,如下所示:tr '\n' ' '
.