📄 sed.1
字号:
.TH SED 1 .SH NAMEsed \- stream editor.SH SYNOPSIS.B sed[.B \-n][.B \-escript ] [.B \-fsfile ] [ file ] ....SH DESCRIPTION.I Sedcopies the named.I files(standard input default) to the standard output,edited according to a script of commands.The.B \-foption causes the script to be taken from file.IR sfile ;these options accumulate.If there is just one.B \-eoption and no.BR \-f 's,the flag.B \-emay be omitted.The.B \-noption suppresses the default output..PPA script consists of editing commands, one per line,of the following form:.IP[address [, address] ] function [arguments].PPIn normal operation.I sedcyclically copies a line of input into a.I pattern space(unless there is something left aftera `D' command),applies in sequenceall commands whose.I addressesselect that pattern space,and at the end of the script copies the pattern spaceto the standard output (except under.BR \-n )and deletes the pattern space..PPAn.I addressis either a decimal number that countsinput lines cumulatively across files, a `$' thataddresses the last line of input, or a context address,`/regular expression/', in the style of.IR ed (1)modified thus:.IPThe escape sequence `\en' matches anewline embedded in the pattern space..PPA command line with no addresses selects every pattern space..PPA command line withone address selects each pattern space that matches the address..PPA command line withtwo addresses selects the inclusive range from the firstpattern space that matches the first address throughthe next pattern space that matches the second.(If the second address is a number less than or equalto the line number first selected, only oneline is selected.)Thereafter the process is repeated, looking again for thefirst address..PPEditing commands can be applied only to non-selected patternspaces by use of the negation function `!' (below)..PPIn the following list of functions the maximum number of permissible addressesfor each function is indicated in parentheses..PPAn argument denoted.I textconsists of one or more lines,all but the last of which end with `\e' to hide thenewline.Backslashes in text are treated like backslashesin the replacement string of an `s' command,and may be used to protect initial blanks and tabsagainst the stripping that is done onevery script line..PPAn argument denoted.I rfileor.I wfilemust terminate the commandline and must be preceded by exactly one blank.Each.I wfileis created before processing begins.There can be at most 10 distinct.I wfilearguments..TP(1)\|a\e.br.ns.TP.I text.brAppend.Place.I texton the output beforereading the next input line..TP.RI (2)\|b " label"Branch to the `:' command bearing the.IR label .If.I labelis empty, branch to the end of the script..TP(2)\|c\e.br.ns.TP.I text.brChange.Delete the pattern space.With 0 or 1 address or at the end of a 2-address range, place.I texton the output.Start the next cycle..TP(2)\|dDelete the pattern space.Start the next cycle..TP(2)\|DDelete the initial segment of the pattern space through the first newline.Start the next cycle..TP(2)\|gReplace the contents of the pattern spaceby the contents of the hold space..TP(2)\|GAppend the contents of the hold space to the pattern space..TP(2)\|hReplace the contents of the hold space by the contents of the pattern space..TP(2)\|HAppend the contents of the pattern space to the hold space..TP(1)\|i\e.br.ns.TP.I textInsert.Place.I texton the standard output..TP(2)\|lList the pattern space on the standard output in anunambiguous form.Non-printing characters are spelled in two digit ascii,and long lines are folded..TP(2)\|nCopy the pattern space to the standard output.Replace the pattern space with the next line of input..TP(2)\|NAppend the next line of input to the pattern spacewith an embedded newline.(The current line number changes.).TP(2)\|pPrint.Copy the pattern space to the standard output..TP(2)\|PCopy the initial segment of the pattern space throughthe first newline to the standard output..TP(1)\|qQuit.Branch to the end of the script.Do not start a new cycle..TP.RI (2)\|r " rfile"Read the contents of.IR rfile .Place them on the output before readingthe next input line..TP.RI (2)\|s /regular\ expression/replacement/flagsSubstitute the.I replacementstring for instances of the.I regular expressionin the pattern space.Any character may be used instead of `/'.For a fuller description see.IR ed (1)..I Flagsis zero or more of.RS.TPgGlobal.Substitute for all nonoverlapping instances of the.I regular expressionrather than just thefirst one..TPpPrint the pattern space if a replacement was made..TP.RI w " wfile"Write.Append the pattern space to.I wfileif a replacementwas made..RE.TP.RI (2)\|t " label"Test.Branch to the `:' command bearing the.I labelif anysubstitutions have been made since the most recentreading of an input line or execution of a `t'.If .I labelis empty, branch to the end of the script..TP.RI (2)\|w " wfile"Write.Append the pattern space to.IR wfile ..TP.RI (2)\|xExchange the contents of the pattern and hold spaces..TP.RI (2)\|y /string1/string2/Transform.Replace all occurrences of characters in.I string1with the corresponding character in.I string2.The lengths of.Istring1and.I string2must be equal..TP.RI (2)! " function"Don't.Apply the.I function(or group, if.I functionis `{') only to lines.I notselected by the address(es)..TP.RI (0)\|: " label"This command does nothing; it bears a.I labelfor `b' and `t' commands to branch to..TP(1)\|=Place the current line number on the standard output as a line..TP(2)\|{Execute the following commands through a matching `}'only when the pattern space is selected..TP(0)\|An empty command is ignored..SH SEE ALSOed(1), grep(1), awk(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -