当前位置:文档之家› sed_4.2.1_man_中文

sed_4.2.1_man_中文

本文参照sed 4.2.1的man原文翻译。

蓝色字体为man原文,黑色字体是我的译文。

水平有限,难免错漏,欢迎各位指正!GNU文档的精髓在info页,而不是man页。

当然更希望有同仁将sed的info页翻译出来,方便大家更扎实地运用好sed这个功能强大的工具。

翻译者:李启训。

NAME名称sed - stream editor for filtering and transforming text用于过滤和转换文本的流编辑器。

SYNOPSIS提要sed [OPTION]... {script-only-if-no-other-script} [input-file]...DESCRIPTION描述Sed is a stream editor. A stream editor is used to perform basic texttransformations on an input stream (a file or input from a pipeline).While in some ways similar to an editor which permits scripted edits(such as ed), sed works by making only one pass over the input(s), andis consequently more efficient. But it is sed's ability to filter textin a pipeline which particularly distinguishes it from other types ofeditors.Sed 是一个流编辑器。

流编辑器用于转换输入流(文件或者来自管道)的基本文本。

虽然在某些方面它类似于允许脚本编辑的编辑器(比如ed),但是sed只对一次传递的输入进行操作,当然更加高效。

除此以外,因为sed能够过滤来自管道中的文本,这明显区别于其他类型的编辑器。

-n, --quiet, --silentsuppress automatic printing of pattern space抑制模式空间的自动输出。

-e script, --expression=scriptadd the script to the commands to be executed添加脚本给命令,以便执行。

-f script-file, --file=script-fileadd the contents of script-file to the commands to be executed添加脚本文件的内容,以便执行。

--follow-symlinksfollow symlinks when processing in place就地处理时跟随符号链接。

-i[SUFFIX], --in-place[=SUFFIX]edit files in place (makes backup if extension supplied)就地编辑文件(如果提供扩展,则备份文件)。

-l N, --line-length=Nspecify the desired line-wrap length for the `l' command为l命令指定所预期的行的长度。

--posixdisable all GNU extensions.禁用所有GNU扩展。

-r, --regexp-extendeduse extended regular expressions in the script.在脚本中使用扩展正则表达式。

-s, --separateconsider files as separate rather than as a single continuouslong stream.分开多个文件,而不是把多个文件当作一个连续的长“流”。

-u, --unbufferedload minimal amounts of data from the input files and flush theoutput buffers more often从输出文件导入最少数量的数据,更频繁地刷新输出缓存。

--helpdisplay this help and exit显示这个帮助然后退出。

--versionoutput version information and exit输出版本信息然后退出。

If no -e, --expression, -f, or --file option is given, then the firstnon-option argument is taken as the sed script to interpret. Allremaining arguments are names of input files; if no input files arespecified, then the standard input is read.如果没有指定-e, --expression, -f, 或者 --file选项,第一个无选项参数会被当作sed脚本进行编译。

其他所有的参数都认为是输入文件的名称;如果没有指定输入文件,将从标准输入读取输入。

GNU sed home page:</software/sed/>. General helpusing GNU software:</gethelp/>. E-mail bug reportsto:<bug-gnu-utils@>. Be sure to include the word ``sed'' some‐where in the ``Sub j ect:'' field.GNU sed的主页是: </software/sed/>。

使用GNU软件的普通帮助在: </gethelp/>。

报告错误请发电子邮件到:<bug-gnu-utils@>,请务必在“主题”字段中的某个地方包含``sed''字样。

COMMAND SYNOPSIS命令提要This is j ust a brief synopsis of sed commands to serve as a reminder tothose who already know sed; other documentation (such as the texinfodocument) must be consulted for fuller descriptions.这只是sed命令的简单提要,为的是给已经了解sed的人士做一个提醒;其他文档(比如texinfo 文档)一定会有更详细的描述。

Z ero-address ``commands''不带地址的命令: labelL abel for b and t commands.为b或者t命令记上标签。

#commentThe comment extends until the next newline (or the end of a -escript fragment).comment可以延伸,直到下一个新行(或者是一个 -e脚本段落的结尾)。

} The closing bracket of a { } block.{ }块的闭合框。

Z ero- or One- address commands不带或者只带一个地址的命令。

= Print the current line number.打印当前行号a \text Append text, which has each embedded newline preceded by a back‐slash.追加text,text可以通过预先写入反斜杠(\)符号来插入新行。

i \text Insert text, which has each embedded newline preceded by a back‐slash.插入text,text可以通过预先写入反斜杠(\)符号来插入新行。

q [exit-code]Immediately quit the sed script without processing any moreinput, except that if auto-print is not disabled the currentpattern space will be printed. The exit code argument is a GNUextension.立刻退出sed脚本而无需处理其他的输入,除非自动打印没有被禁止模式空间被打印出来。

[exit-code]是GUN的扩展。

Q [exit-code]Immediately quit the sed script without processing any moreinput. This is a GNU extension.立刻退出sed脚本,无需处理任何其他输入。

这是GNU的扩展。

r filenameAppend text read from filename.从filename读入text并追加在后面。

R filenameAppend a line read from filename. Each invocation of the com‐mand reads a line from the file. This is a GNU extension.从filename读入一行并追加在后面。

每个命令调用从file中读取一行。

这是GNU扩展。

Commands which accept address ranges接受地址范围的命令{ Begin a block of commands (end with a }).开始一个命令块。

b labelBranch to label; if label is omitted, branch to end of script.程序转移到label处执行;如果label被省略,则转移到脚本结尾。

t labelIf a s/// has done a successful substitution since the lastinput line was read and since the last t or T command, thenbranch to label; if label is omitted, branch to end of script.如果本次输入行读入之后,离t或者T命令最近的s///结构已经成功替换,那么程序转移到label处执行;如果label被省略,则转移到脚本结尾。

相关主题