Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
拥有 xmlstarlet 1.3.1。
给定文件.xml:
<entry> <message>Line 1 Line 2 and so on </message> </entry>
如何选择消息并在一行中显示其值,而新行替换为“@”如下:
Line 1@Line 2 and so on
xmlstarlet sel -t -v "/entry/message" file.xml | tr -s "\n" "@"
请注意,在您的示例中,等等之后还有一个额外的换行符。