我正在尝试对某些手册页进行一些格式化,我需要添加
] hfill \\
某些标题。我想做这个
NAME
env - run a program in a modified environment
SYNOPSIS
env [-] [-i] [-u name] [--ignore-environment]
[--unset=name] [name=value]... [command [args...]]
DESCRIPTION
This manual page documents the GNU version of env. env
runs a command with an environment modified as specified
by the command line...
进入这个
\item[NAME] \hfill \\
env - run a program in a modified environment
\item[SYNOPSIS] \hfill \\
env [-] [-i] [-u name] [-\hspace{.01cm}-ignore-environment]
[-\hspace{.01cm}-unset=name] [name=value]... [command [args...]]
\item[DESCRIPTION] \hfill \\
This manual page documents the GNU version of env. env
runs a command with an environment modified as specified
by the command line...
我得到了“\item[”部分,但出于某种原因我无法得到另一半。我正在使用的命令:
/[A-Z]/s/$/\] \\hfill \\\\/
有效但出现在我不想要的行上。
最佳答案
试试这个,假设标题只有一行以大写字母开头
sed '/^[A-Z]/ s/.*/\\item[&] \\hfill \\\\/' YourFile
对于 \hspace{.01cm}
,你应该定义它应该发生的时间(条件)
关于linux - 使用 sed 向特定行添加字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32623385/