📄 ed.1
字号:
given.I "command list\^"is executed with \fB.\fP initially set to that line.A single command or the first of a list of commandsappears on the same line as the global command.All lines of a multi-line list except the last line must be ended with a \fB\^\e\fP;.B a,.B i,and.B ccommands and associated input are permitted;the \fB.\fP terminating input mode may be omitted if it would be thelast line of the.IR "command list" .An empty.I "command list\^"is equivalent to the.B pcommand.The.B g,.B G,.B v,and.B Vcommandsare.I not\^permitted in the.IR "command list" .See alsoRESTRICTIONSand the last paragraph beforeFILESbelow..HP.BI (\|1\|,\|$\|)G/ \s-1RE\s+1 /\^.brIn the interactive Globalcommand, the first stepis to mark every line that matches the given\s-1RE\s+1.Then, for every such line, that line is printed, \fB.\fP is changed to that line, andany.I one\^command (other than one of the.B a,.B c,.B i,.B g,.B G,.B v,and.B Vcommands)may be input and is executed.After the execution of that command, the next marked line is printed, and so on;a new-line acts as a null command;an \fB&\fP causes the re-execution of the most recent command executed withinthe current invocation of.IR G .Note that thecommands inputas part of the execution of the.B Gcommandmayaddress and affect.I any\^lines in the buffer.The.B Gcommand can be terminated by an interrupt signal (\s-1ASCII\s0 \s-1DEL\s0 or \s-1BREAK\s0)..HP.br.B h.brThe .B helpcommand gives a short error message that explainsthe reason for the most recent \fB?\fP diagnostic..HP.B H.brThe .B helpcommand causes.PN edto enter a mode in which error messages areprinted for all subsequent \fB?\fP diagnostics.It will also explain the previous \fB?\fP ifthere was one.The.B Hcommand alternately turns this modeon and off; it is initially off..HP.B (\|.\|)i.br.ns.HP<text>.br.ns.HP.if t .rs.if t .sp -.5v\&\fB.\fP.brThe insertcommand inserts the given text before the addressed line;\&\fB.\fP is left at the last inserted line, or, if there were none,at the addressed line.This command differs from the.B acommand only in the placement of theinputtext.Address 0 is not legal for this command.The maximum number of characters that may be entered from aterminal is 256 per line (including the new line character)..HP.B (\|.\|,\|.+1\|)j.brThe joincommand joins contiguous lines by removing the appropriate new-line characters.If exactly one address is given, this command does nothing..HP.BI (\|.\|)k x\^.brThe mark command marks the addressed line withname.IR x ,which must be a lower-case letter.The address \fI\(fmx\fP\^ then addresses this line;\&\fB.\fP is unchanged..HP.B (\|.\|,\|.\|)l.brThe listcommandprints the addressed lines in an unambiguous way:a few non-printing characters (for example,.IR "tab, backspace" )are represented by (hopefully) mnemonic overstrikes, all other non-printingcharacters areprinted in octal,and long lines are folded.An.B lcommand may be appended to any other commandother than.B e,.B f,.B r,or.B w..HP.BI (\|.\|,\|.\|)m a\^.brThe .B movecommand repositions the addressed line(s) after the lineaddressed by.I a.Address 0 is legal for.I a\^and causes the addressed line(s) to be moved tothe beginning of the file;it is an error if address.I a\^falls within the range of moved lines;\&\fB.\fP is left at the last line moved..HP.B (\|.\|,\|.\|)n.brThe numbercommand prints the addressed lines,preceding each line by itsline number and a tab character;\&\fB.\fP is left at the last line printed.The.B ncommandmaybe appended to any other commandother than.B e,.B f,.B r,or.B w..HP.B (\|.\|,\|.\|)p.brThe printcommand prints the addressed lines;\&\fB.\fP is left at the last line printed.The.B pcommandmaybe appended to any other commandother than.B e,.B f,.B r,or.B w;for example, \fIdp\fP\^deletes the current line and prints thenew current line..HP.br.B P.brThe editor will prompt with a \fB\(**\fP forall subsequent commands.The.B Pcommand alternately turns this mode on and off; it isinitially off..HP.B q.brThe quitcommand causes.PN edto exit.No automatic writeof a file is done(but see DIAGNOSTICS below)..HP.br.B Q.brThe editor exits withoutchecking if changes have been made in the buffer since thelast.B wcommand..HP.BI (\|$\|)r " file\^".brThe readcommandreads in the given file after the addressed line.If no file name is given,the currently-remembered file name, if any, is used(see.B eand.B fcommands).The currently-remembered file name is.I not\^changed unless.I file\^is the very first file namementionedsince.PN edwas invoked.Address 0 is legal for.I r\^and causes thefile to be read at the beginning of the buffer.If the read is successful, the number of charactersread is typed;\&\fB.\fP is set to the last line read in.If.I file\^is replaced by \fB!\fP, the rest of the lineis taken to be ashell (\fIsh\fP\^(1))command whose output is to be read.For example, "$r !ls" appends current directoryto the end of the file being edited.Such ashellcommand is.B notremembered as the current file name..HP.BI (\|.\|,\|.\|)s/ \s-1RE\s+1 / replacement /\^\ \ \ \ \ \ \ \ or.br.ns.HP.BI (\|.\|,\|.\|)s/ \s-1RE\s+1 / replacement /g\^.brThe substitutecommand searches each addressedline for an occurrence of the specified \s-1RE\s+1.In each line in which a match is found,all (non-overlapped) matched strings arereplaced by the.I replacement\^if the global replacement indicator \fBg\fP appears after the command.If the global indicator does not appear, only the first occurrenceof the matched string is replaced.It is an error for the substitution to fail on.I all\^addressed lines.Any character other than space or new-linemay be used instead of \fB/\fP to delimit the \s-1RE\s+1andthe.IR replacement;\&\fB.\fP is left at the last line on which a substitution occurred.See also the last paragraph beforeFILESbelow..IPAn ampersand (\^\fB&\fP\^) appearing in the.I replacement\^is replaced by the string matching the \s-1RE\s+1 on the current line.The special meaning of \fB&\fP in this context may besuppressed by preceding it by \fB\^\e\fP.As a more general feature,the characters\fB\^\e\fP\fIn\fP\^,where.I n\^is a digit,are replaced by the text matched by the.IR n \-thregular subexpressionof the specified \s-1RE\s+1enclosed between \fB\^\e(\fP and \fB\^\e)\fP.Whennested parenthesized subexpressionsare present,.I n\^is determined by counting occurrences of \fB\^\e(\fP starting from the left.When the character \fB%\fP is the only characterin the.IR replacement,the.I replacement\^used in the most recent substitutecommand is used as the.I replacement\^in the current substitute command.The \fB%\fP loses its special meaning when it isin a replacement string of more than onecharacter or is preceded by a \fB\^\e\fP..IPA line may be split by substituting a new-line character into it.The new-line in the.I replacement\^must be escaped by preceding it by \fB\^\e\fP.Such substitution cannot be done as part of a.B gor.B vcommand list..HP.BI (\|.\|,\|.\|)t a\^.brThis command acts just like the.B mcommand, except that a.I copy\^of the addressed lines is placedafter address.I a\^(which may be 0);\&\fB.\fP is left at the last line of the copy..HP.B u.brThe.B undocommand nullifies the effect of the most recentcommand that modified anything in the buffer, namelythe most recent.B a,.B c,.B d,.B g,.B i,.B j,.B m,.B r,.B s,.B t,.B v,.B G,or.B Vcommand..HP.BI (\|1\|,\|$\|)v/ \s-1RE\s+1 / "command list\^".brThis command is the same as the global command.B gexcept that the.I "command list\^"is executedwith \fB.\fP initially set to every linethat does.I not\^match the\s-1RE\s+1..HP.BI (\|1\|,\|$\|)V/ \s-1RE\s+1 /\^.brThis command is the same as the interactive global command.B Gexceptthat the lines that are marked during the first step are those that do.I not\^match the\s-1RE\s+1..HP.BI (\|1\|,\|$\|)w " file\^".brThe writecommand writes the addressed lines intothe named file.If the file does not exist,it is created with mode 666 (readable and writable by everyone),unless your.I umask\^setting(see.IR sh (1))dictates otherwise.The currently-remembered file name is.I not\^changed unless.I file\^is the very first file name mentioned since.PN edwas invoked.If no file name is given,the currently-remembered file name, if any, is used(see.B eand.B fcommands);\&\fB.\fP is unchanged.If the command is successful, the number of characters written istyped.If.I file\^is replaced by \fB!\fP, the rest of the lineis taken to be ashell (\fIsh\fP\^(1))command whose standard input is the addressed lines.Such ashellcommand is.I not\^remembered as the current file name..HP.B (\|$\|)=.brThe line number of the addressed line is typed;\&\fB.\fP is unchanged by this command..HP.BI ! "shell\| command\^".brThe remainder of the line after the \fB!\fP is sentto the UNIX Systemshell (\fIsh\fP\^(1)) to be interpreted as a command.Within the text of that command, the unescaped character.B %is replaced with the remembered file name;if a.B !appears as the first character of the shell command,it is replaced with the text of the previous shell command.Thus,.B !!will repeat the last shell command.If any expansion is performed, the expanded line is echoed;\&\fB.\fP is unchanged..HP.BR (\|.+1\|) <new-line>.brAn address alone on a line causes the addressed line to be printed.A new-line alone is equivalent to \fB.+1p\fP; it is usefulfor stepping forward through the buffer..PPIf an interrupt signal (\s-1ASCII\s0 \s-1DEL\s0 or \s-1BREAK\s0) is sent,.PN edprints a \fB?\fP and returns to.B itscommand level..NXR "ed line editor" "interrupt signal".PPSome size limitations:512 characters per line,256 characters per global command list,64 characters per file name,and 128K characters in the buffer.The limit on the number of lines depends on the amount of user memory:each line takes 1 word..PPWhen reading a file,.PN eddiscards ASCII NUL charactersand all characters after the last new-line.Files(for example,.BR a.out )thatcontain characters not in theASCIIset (bit8 on) cannot be edited by.PN ed ..PPIf the closing delimiter of a \s-1RE\s+1 or of areplacement string (for example, \fB/\fP) would be the lastcharacter before a new-line,that delimiter may be omitted, inwhich case the addressed lineis printed.The following pairs of commands are equivalent:.PD 0.RS.TP 10s/s1/s2s/s1/s2/p.TPg/s1g/s1/p.TP?s1?s1?.RE.SH Restrictions.NXR "ed line editor" "restricted"A.B !command cannot be subject to a.B gor a.B vcommand..PPThe.B !commandand the.B !escape from the.B e,.B r,and.B wcommandscannot be used if the the editor is invoked from a restrictedshell. For further information, see .MS sh 1 ..PPThe sequence \fB\^\en\fP in a \s-1RE\s+1 does notmatch a new-line character..PPThe.B lcommand mishandles DEL..SH Diagnostics.NXR "ed line editor" "diagnostics".TP 10.B ?for command errors..TP.BI ? file\^for an inaccessible file..br(use the helpand Helpcommands for detailed explanations)..PD.PPIf changes have been made in the buffer since the last.B wcommand that wrote the entire buffer,.PN edwarns the user if an attempt is made to destroy.PN ed 'sbuffer via the.B eor.B qcommands:itprints.B ?andallows one to continue editing.A second.B eor.B qcommandat this point will take effect.The \fB\-\fP command-line option inhibits this feature..SH Files.PD 0.TP 10/tmp/e#temporary;# is the process number..TPed\s+4.\s-4hupwork is saved here if the terminal is hung up..SH See Alsogrep(1), sed(1), sh(1), stty(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -