尝试编写 Sed 脚本将手册页转换为 Latex。 需要在第一个非空白字符为“+”或“-”的每行末尾添加一个空格和\\。我做了什么:
/[. \t]-[a-zA-Z]/s/$/ \\\\/
/[. \t]+[a-zA-Z]/s/$/ \\\\/
我认为手册页在遇到“-”或“+”之前有空格或制表符,因此我将空格和制表符添加到地址中。我的问题是,它将\\添加到带有“-”或“+”字符的每一行的末尾。示例输出:
-daystart \\
Measure times (for -amin, -atime, -cmin, ctime, \\
-mmin, and -mtime) from the beginning of today \\
rather than from 24 hours ago.
它必须位于单个 Sed 脚本中,该脚本可以将多个手册页转换为 Latex,因此行号作为地址将不起作用。
最佳答案
以下内容对您有用吗?
/^[. \t][. \t]*[-+][a-zA-Z]/s/$/ \\\\/
关于linux - Sed:添加到特定行的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35143453/