0

hi I want to write a unix script, while using the SED editor, to output the text, in this case a variable, to the result file but highlighted it in bold, is it possible to do that? can you tell me how?

eg. in text.txt

Code:

sed '$ a\
'$variable'
     ' <text.txt >text2.txt

so it will add the variable after the last line in the text.txt file, but preferably in bold

Thanks Robert

4

1 回答 1

-1

纯文本文件没有粗体。粗体是一种显示文本的方式。根据您用于显示文本的工具,您可能能够以告诉工具以粗体显示的方式标记单词。有不同的方法可以做到这一点,不同的工具可以识别:

HTML tag, recognized by many browsers and editors:
"foo" => "<b>foo</b>"

Enriched text tag, recognized by emacs in enriched-mode and some email tools
"foo" => "<bold>foo</bold>"

在尝试自动执行之前,您应该手动尝试。

假设您决定使用 HTML。现在使用 sed 将该行添加到文件的末尾:

sed '$a\
<b>$variable</b>
' text.txt > text2.txt
于 2012-07-18T12:33:05.530 回答