我有这个练习,我解决不了。
用空字符串替换所有的para>和标记。如果结果行为空,则删除该行。(您可能需要使用花括号来实现这一点。)。
这是我获得的文档(web.docbook)的一部分:
<para>
This is an article about the World Wide Web.
The World Wide Web is a collection of documents that are linked to
one another. The Web is <emphasis>not</emphasis> the same as the
Internet. The Internet is a world-wide network of networks, and it
does far more than simply serve up Web pages.
</para>
<para>Tim Berners-Lee, the inventor of the World Wide Web, put special
emphasis on the portability of web pages. Rather than create a
proprietary format, he made Web pages dependent only upon plain ASCII
text.</para>
<para>
Web pages are written in a markup language called HTML. Here is what it
looks like. The < and > mark off elements.
</para>
<listing>
<body>
<div id="top-navig">
<a id="top"></a>
<a href="index.html">CIT 040 Index</a>
&gt;
Assignment 1
</div>我能够解决第一部分的练习,这是完美的,但我不知道如何只删除那些空行,这是我的替代结果。
如果你能帮我,我会非常感激的!
发布于 2022-11-21 02:15:00
不确定你是否真的是,假设使用一些条件词和花括号,但这很好;)并对文本做你想要的.
$ sed -E '/^<\/?para>$/d;s/<\/?para>//g' web.docbook
This is an article about the World Wide Web.
The World Wide Web is a collection of documents that are linked to
one another. The Web is <emphasis>not</emphasis> the same as the
Internet. The Internet is a world-wide network of networks, and it
does far more than simply serve up Web pages.
Tim Berners-Lee, the inventor of the World Wide Web, put special
emphasis on the portability of web pages. Rather than create a
proprietary format, he made Web pages dependent only upon plain ASCII
text.
Web pages are written in a markup language called HTML. Here is what it
looks like. The < and > mark off elements.
<listing>
<body>
<div id="top-navig">
<a id="top"></a>
<a href="index.html">CIT 040 Index</a>
&gt;
Assignment 1
</div>
$https://stackoverflow.com/questions/74513357
复制相似问题