linux - Sed:添加到特定行的末尾

标签 linux unix sed latex ascii

尝试编写 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/

相关文章:

从程序集调用 main

regex - 使用 sed 提取单引号之间的字符串

Python spynner 登录页面问题

database - 使用 cURL 创建 couchdb 独立附件

linux - 如何保护shell脚本代码

bash - while read 行在第一次迭代后停止

linux - 如何在 *nix 上查找/grep 目录名称匹配 "x"但不匹配 "y"的所有路径?

Java 内存消耗, "top"和 HP-Ux

regex - sed 在时间戳周围添加引号

regex - Bash 脚本 : Append parent directories to filenames