📄 psed.1
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "S2P 1".TH S2P 1 "2008-01-23" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"psed \- a stream editor.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 2\& psed [\-an] script [file ...]\& psed [\-an] [\-e script] [\-f script\-file] [file ...]\&\& s2p [\-an] [\-e script] [\-f script\-file].Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"A stream editor reads the input stream consisting of the specified files(or standard input, if none are given), processes is line by line byapplying a script consisting of edit commands, and writes resulting linesto standard output. The filename `\f(CW\*(C`\-\*(C'\fR' may be used to read standard input..PPThe edit script is composed from arguments of \fB\-e\fR options andscript-files, in the given order. A single script argument may be specifiedas the first parameter..PPIf this program is invoked with the name \fIs2p\fR, it will act as ased-to-Perl translator. See \*(L"sed Script Translation\*(R"..PP\&\fBsed\fR returns an exit code of 0 on success or >0 if an error occurred..SH "OPTIONS".IX Header "OPTIONS".IP "\fB\-a\fR" 4.IX Item "-a"A file specified as argument to the \fBw\fR edit command is by defaultopened before input processing starts. Using \fB\-a\fR, opening of suchfiles is delayed until the first line is actually written to the file..IP "\fB\-e\fR \fIscript\fR" 4.IX Item "-e script"The editing commands defined by \fIscript\fR are appended to the script.Multiple commands must be separated by newlines..IP "\fB\-f\fR \fIscript-file\fR" 4.IX Item "-f script-file"Editing commands from the specified \fIscript-file\fR are read and appendedto the script..IP "\fB\-n\fR" 4.IX Item "-n"By default, a line is written to standard output after the editing scripthas been applied to it. The \fB\-n\fR option suppresses automatic printing..SH "COMMANDS".IX Header "COMMANDS"\&\fBsed\fR command syntax is defined as.PP [\fIaddress\fR[\fB,\fR\fIaddress\fR]][\fB!\fR]\fIfunction\fR[\fIargument\fR].PPwith whitespace being permitted before or after addresses, and betweenthe function character and the argument. The \fIaddress\fRes and theaddress inverter (\f(CW\*(C`!\*(C'\fR) are used to restrict the application of acommand to the selected line(s) of input..PPEach command must be on a line of its own, except where noted inthe synopses below..PPThe edit cycle performed on each input line consist of reading the line(without its trailing newline character) into the \fIpattern space\fR,applying the applicable commands of the edit script, writing the finalcontents of the pattern space and a newline to the standard output.A \fIhold space\fR is provided for saving the contents of thepattern space for later use..Sh "Addresses".IX Subsection "Addresses"A sed address is either a line number or a pattern, which may be combinedarbitrarily to construct ranges. Lines are numbered across all input files..PPAny address may be followed by an exclamation mark (`\f(CW\*(C`!\*(C'\fR'), selectingall lines not matching that address..IP "\fInumber\fR" 4.IX Item "number"The line with the given number is selected..IP "\fB$\fR" 4.IX Item "$"A dollar sign (\f(CW\*(C`$\*(C'\fR) is the line number of the last line of the input stream..IP "\fB/\fR\fIregular expression\fR\fB/\fR" 4.IX Item "/regular expression/"A pattern address is a basic regular expression (see \&\*(L"Basic Regular Expressions\*(R"), between the delimiting character \f(CW\*(C`/\*(C'\fR.Any other character except \f(CW\*(C`\e\*(C'\fR or newline may be used to delimit apattern address when the initial delimiter is prefixed with abackslash (`\f(CW\*(C`\e\*(C'\fR')..PPIf no address is given, the command selects every line..PPIf one address is given, it selects the line (or lines) matching theaddress..PPTwo addresses select a range that begins whenever the first addressmatches, and ends (including that line) when the second address matches.If the first (second) address is a matching pattern, the second address is not applied to the very same line to determine the end ofthe range. Likewise, if the second address is a matching pattern, thefirst address is not applied to the very same line to determine thebegin of another range. If both addresses are line numbers,and the second line number is less than the first line number, thenonly the first line is selected..Sh "Functions".IX Subsection "Functions"The maximum permitted number of addresses is indicated with eachfunction synopsis below..PPThe argument \fItext\fR consists of one or more lines following the command.Embedded newlines in \fItext\fR must be preceded with a backslash. Otherbackslashes in \fItext\fR are deleted and the following character is takenliterally..IP "[1addr]\fBa\e\fR \fItext\fR" 4.IX Item "[1addr]a text"Write \fItext\fR (which must start on the line following the command)to standard output immediately before reading the next lineof input, either by executing the \fBN\fR function or by beginning a new cycle..IP "[2addr]\fBb\fR [\fIlabel\fR]" 4.IX Item "[2addr]b [label]"Branch to the \fB:\fR function with the specified \fIlabel\fR. If no labelis given, branch to the end of the script..IP "[2addr]\fBc\e\fR \fItext\fR" 4.IX Item "[2addr]c text"The line, or range of lines, selected by the address is deleted. The \fItext\fR (which must start on the line following the command)is written to standard output. With an address range, this occurs atthe end of the range..IP "[2addr]\fBd\fR" 4.IX Item "[2addr]d"Deletes the pattern space and starts the next cycle..IP "[2addr]\fBD\fR" 4.IX Item "[2addr]D"Deletes the pattern space through the first embedded newline or to the end.If the pattern space becomes empty, a new cycle is started, otherwiseexecution of the script is restarted..IP "[2addr]\fBg\fR" 4.IX Item "[2addr]g"Replace the contents of the pattern space with the hold space..IP "[2addr]\fBG\fR" 4.IX Item "[2addr]G"Append a newline and the contents of the hold space to the pattern space..IP "[2addr]\fBh\fR" 4.IX Item "[2addr]h"Replace the contents of the hold space with the pattern space..IP "[2addr]\fBH\fR" 4.IX Item "[2addr]H"Append a newline and the contents of the pattern space to the hold space..IP "[1addr]\fBi\e\fR \fItext\fR" 4.IX Item "[1addr]i text"Write the \fItext\fR (which must start on the line following the command)to standard output..IP "[2addr]\fBl\fR" 4.IX Item "[2addr]l"Print the contents of the pattern space: non-printable characters areshown in C\-style escaped form; long lines are split and have a trailing`\f(CW\*(C`\e\*(C'\fR' at the point of the split; the true end of a line is marked witha `\f(CW\*(C`$\*(C'\fR'. Escapes are: `\ea', `\et', `\en', `\ef', `\er', `\ee' for\&\s-1BEL\s0, \s-1HT\s0, \s-1LF\s0, \s-1FF\s0, \s-1CR\s0, \s-1ESC\s0, respectively, and `\e' followed by a three-digitoctal number for all other non-printable characters..IP "[2addr]\fBn\fR" 4.IX Item "[2addr]n"If automatic printing is enabled, write the pattern space to the standardoutput. Replace the pattern space with the next line of input. Ifthere is no more input, processing is terminated..IP "[2addr]\fBN\fR" 4.IX Item "[2addr]N"Append a newline and the next line of input to the pattern space. Ifthere is no more input, processing is terminated..IP "[2addr]\fBp\fR" 4.IX Item "[2addr]p"Print the pattern space to the standard output. (Use the \fB\-n\fR optionto suppress automatic printing at the end of a cycle if you want toavoid double printing of lines.).IP "[2addr]\fBP\fR" 4.IX Item "[2addr]P"Prints the pattern space through the first embedded newline or to the end..IP "[1addr]\fBq\fR" 4.IX Item "[1addr]q"Branch to the end of the script and quit without starting a new cycle..IP "[1addr]\fBr\fR \fIfile\fR" 4.IX Item "[1addr]r file"Copy the contents of the \fIfile\fR to standard output immediately beforethe next attempt to read a line of input. Any error encountered whilereading \fIfile\fR is silently ignored..IP "[2addr]\fBs/\fR\fIregular expression\fR\fB/\fR\fIreplacement\fR\fB/\fR\fIflags\fR" 4.IX Item "[2addr]s/regular expression/replacement/flags"Substitute the \fIreplacement\fR string for the first substring inthe pattern space that matches the \fIregular expression\fR.Any character other than backslash or newline can be used instead of a slash to delimit the regular expression and the replacement.To use the delimiter as a literal character within the regular expressionand the replacement, precede the character by a backslash (`\f(CW\*(C`\e\*(C'\fR')..SpLiteral newlines may be embedded in the replacement string bypreceding a newline with a backslash..SpWithin the replacement, an ampersand (`\f(CW\*(C`&\*(C'\fR') is replaced by the stringmatching the regular expression. The strings `\f(CW\*(C`\e1\*(C'\fR' through `\f(CW\*(C`\e9\*(C'\fR' arereplaced by the corresponding subpattern (see \*(L"Basic Regular Expressions\*(R").To get a literal `\f(CW\*(C`&\*(C'\fR' or `\f(CW\*(C`\e\*(C'\fR' in the replacement text, precede itby a backslash..SpThe following \fIflags\fR modify the behaviour of the \fBs\fR command:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -