12a456239SPeter Wemm.\" $FreeBSD$ 200c2adfeSPhilippe Charnier.Dd May 21, 1993 300c2adfeSPhilippe Charnier.Dt ED 1 400c2adfeSPhilippe Charnier.Os 500c2adfeSPhilippe Charnier.Sh NAME 6d165d4acSAndrew Moore.\" ed, red \- text editor 7daa40efdSAlexey Zelkin.Nm ed , 8daa40efdSAlexey Zelkin.Nm red 900c2adfeSPhilippe Charnier.Nd text editor 1000c2adfeSPhilippe Charnier.Sh SYNOPSIS 11be8b1497SRuslan Ermilov.Nm 1200c2adfeSPhilippe Charnier.Op Fl 1300c2adfeSPhilippe Charnier.Op Fl sx 1400c2adfeSPhilippe Charnier.Op Fl p Ar string 1500c2adfeSPhilippe Charnier.Op Ar file 16d165d4acSAndrew Moore.\" .LP 17d165d4acSAndrew Moore.\" red [-] [-sx] [-p \fIstring\fR] [\fIfile\fR] 1800c2adfeSPhilippe Charnier.Sh DESCRIPTION 1900c2adfeSPhilippe Charnier.Nm Ed 2030154ac8SAndrew Mooreis a line-oriented text editor. 2130154ac8SAndrew MooreIt is used to create, display, modify and otherwise manipulate text 2230154ac8SAndrew Moorefiles. 23d165d4acSAndrew Moore.\" .B red 24d165d4acSAndrew Moore.\" is a restricted 25d165d4acSAndrew Moore.\" .BR ed : 26d165d4acSAndrew Moore.\" it can only edit files in the current 27d165d4acSAndrew Moore.\" directory and cannot execute shell commands. 2812e720d7SRuslan Ermilov.Pp 2930154ac8SAndrew MooreIf invoked with a 3000c2adfeSPhilippe Charnier.Ar file 3130154ac8SAndrew Mooreargument, then a copy of 3200c2adfeSPhilippe Charnier.Ar file 3330154ac8SAndrew Mooreis read into the editor's buffer. 3430154ac8SAndrew MooreChanges are made to this copy and not directly to 3500c2adfeSPhilippe Charnier.Ar file 3630154ac8SAndrew Mooreitself. 3730154ac8SAndrew MooreUpon quitting 38be8b1497SRuslan Ermilov.Nm , 3930154ac8SAndrew Mooreany changes not explicitly saved with a 4000c2adfeSPhilippe Charnier.Em w 4130154ac8SAndrew Moorecommand are lost. 4212e720d7SRuslan Ermilov.Pp 4330154ac8SAndrew MooreEditing is done in two distinct modes: 4400c2adfeSPhilippe Charnier.Em command 4530154ac8SAndrew Mooreand 4600c2adfeSPhilippe Charnier.Em input . 4730154ac8SAndrew MooreWhen first invoked, 4800c2adfeSPhilippe Charnier.Nm 4930154ac8SAndrew Mooreis in command mode. 5030154ac8SAndrew MooreIn this mode commands are read from the standard input and 5130154ac8SAndrew Mooreexecuted to manipulate the contents of the editor buffer. 5230154ac8SAndrew MooreA typical command might look like: 5300c2adfeSPhilippe Charnier.Pp 5400c2adfeSPhilippe Charnier.Sm off 5500c2adfeSPhilippe Charnier.Cm ,s No / Em old Xo 5600c2adfeSPhilippe Charnier.No / Em new 5700c2adfeSPhilippe Charnier.No / Cm g 5800c2adfeSPhilippe Charnier.Xc 5900c2adfeSPhilippe Charnier.Sm on 6000c2adfeSPhilippe Charnier.Pp 6160fd953fSJordan K. Hubbardwhich replaces all occurrences of the string 6200c2adfeSPhilippe Charnier.Em old 6330154ac8SAndrew Moorewith 6400c2adfeSPhilippe Charnier.Em new . 6500c2adfeSPhilippe Charnier.Pp 6630154ac8SAndrew MooreWhen an input command, such as 6700c2adfeSPhilippe Charnier.Em a 6830154ac8SAndrew Moore(append), 6900c2adfeSPhilippe Charnier.Em i 7030154ac8SAndrew Moore(insert) or 7100c2adfeSPhilippe Charnier.Em c 7230154ac8SAndrew Moore(change), is given, 7300c2adfeSPhilippe Charnier.Nm 7430154ac8SAndrew Mooreenters input mode. This is the primary means 7530154ac8SAndrew Mooreof adding text to a file. 7630154ac8SAndrew MooreIn this mode, no commands are available; 7730154ac8SAndrew Mooreinstead, the standard input is written 7830154ac8SAndrew Mooredirectly to the editor buffer. Lines consist of text up to and 7930154ac8SAndrew Mooreincluding a 8000c2adfeSPhilippe Charnier.Em newline 8130154ac8SAndrew Moorecharacter. 8230154ac8SAndrew MooreInput mode is terminated by 8300c2adfeSPhilippe Charnierentering a single period 8412e720d7SRuslan Ermilov.Pq Em .\& 8500c2adfeSPhilippe Charnieron a line. 8600c2adfeSPhilippe Charnier.Pp 8730154ac8SAndrew MooreAll 8800c2adfeSPhilippe Charnier.Nm 8930154ac8SAndrew Moorecommands operate on whole lines or ranges of lines; e.g., 9030154ac8SAndrew Moorethe 9100c2adfeSPhilippe Charnier.Em d 9230154ac8SAndrew Moorecommand deletes lines; the 9300c2adfeSPhilippe Charnier.Em m 9430154ac8SAndrew Moorecommand moves lines, and so on. 9530154ac8SAndrew MooreIt is possible to modify only a portion of a line by means of replacement, 9630154ac8SAndrew Mooreas in the example above. However even here, the 9700c2adfeSPhilippe Charnier.Em s 9830154ac8SAndrew Moorecommand is applied to whole lines at a time. 9900c2adfeSPhilippe Charnier.Pp 10030154ac8SAndrew MooreIn general, 10100c2adfeSPhilippe Charnier.Nm 10230154ac8SAndrew Moorecommands consist of zero or more line addresses, followed by a single 10330154ac8SAndrew Moorecharacter command and possibly additional parameters; i.e., 10430154ac8SAndrew Moorecommands have the structure: 10500c2adfeSPhilippe Charnier.Pp 10600c2adfeSPhilippe Charnier.Sm off 10700c2adfeSPhilippe Charnier.Xo Op "address\ " Op ,address 10800c2adfeSPhilippe Charnier.No command Op parameters 10900c2adfeSPhilippe Charnier.Xc 11000c2adfeSPhilippe Charnier.Sm on 11100c2adfeSPhilippe Charnier.Pp 11210ca1c6cSAndrew MooreThe address(es) indicate the line or range of lines to be affected by the 11310ca1c6cSAndrew Moorecommand. If fewer addresses are given than the command accepts, then 11410ca1c6cSAndrew Mooredefault addresses are supplied. 11500c2adfeSPhilippe Charnier.Sh OPTIONS 11600c2adfeSPhilippe CharnierThe following options are available: 11700c2adfeSPhilippe Charnier.Bl -tag -width indent 11800c2adfeSPhilippe Charnier.It Fl s 119bef84d6bSSheldon HearnSuppress diagnostics. 120bef84d6bSSheldon HearnThis should be used if 12100c2adfeSPhilippe Charnier.Nm Ns 's 12230154ac8SAndrew Moorestandard input is from a script. 12300c2adfeSPhilippe Charnier.It Fl x 12400c2adfeSPhilippe CharnierPrompt for an encryption key to be used in subsequent reads and writes 12530154ac8SAndrew Moore(see the 12600c2adfeSPhilippe Charnier.Em x 12730154ac8SAndrew Moorecommand). 12800c2adfeSPhilippe Charnier.It Fl p Ar string 12900c2adfeSPhilippe CharnierSpecify a command prompt. This may be toggled on and off with the 13000c2adfeSPhilippe Charnier.Em P 13130154ac8SAndrew Moorecommand. 13200c2adfeSPhilippe Charnier.It Ar file 13300c2adfeSPhilippe CharnierSpecify the name of a file to read. If 13400c2adfeSPhilippe Charnier.Ar file 13530154ac8SAndrew Mooreis prefixed with a 13630154ac8SAndrew Moorebang (!), then it is interpreted as a shell command. In this case, 13730154ac8SAndrew Moorewhat is read is 13830154ac8SAndrew Moorethe standard output of 13900c2adfeSPhilippe Charnier.Ar file 14030154ac8SAndrew Mooreexecuted via 14100c2adfeSPhilippe Charnier.Xr sh 1 . 14230154ac8SAndrew MooreTo read a file whose name begins with a bang, prefix the 14330154ac8SAndrew Moorename with a backslash (\\). 14430154ac8SAndrew MooreThe default filename is set to 14500c2adfeSPhilippe Charnier.Ar file 14630154ac8SAndrew Mooreonly if it is not prefixed with a bang. 14700c2adfeSPhilippe Charnier.El 14800c2adfeSPhilippe Charnier.Sh LINE ADDRESSING 14995e6217eSAndrew MooreAn address represents the number of a line in the buffer. 15000c2adfeSPhilippe Charnier.Nm Ed 15130154ac8SAndrew Mooremaintains a 15200c2adfeSPhilippe Charnier.Em current address 15330154ac8SAndrew Moorewhich is 15430154ac8SAndrew Mooretypically supplied to commands as the default address when none is specified. 15530154ac8SAndrew MooreWhen a file is first read, the current address is set to the last line 15630154ac8SAndrew Mooreof the file. In general, the current address is set to the last line 15730154ac8SAndrew Mooreaffected by a command. 15800c2adfeSPhilippe Charnier.Pp 15930154ac8SAndrew MooreA line address is 16030154ac8SAndrew Mooreconstructed from one of the bases in the list below, optionally followed 16130154ac8SAndrew Mooreby a numeric offset. The offset may include any combination 16230154ac8SAndrew Mooreof digits, operators (i.e., 16300c2adfeSPhilippe Charnier.Em + , 16400c2adfeSPhilippe Charnier.Em - 16530154ac8SAndrew Mooreand 16600c2adfeSPhilippe Charnier.Em ^ ) 16730154ac8SAndrew Mooreand whitespace. 16830154ac8SAndrew MooreAddresses are read from left to right, and their values are computed 16930154ac8SAndrew Moorerelative to the current address. 17000c2adfeSPhilippe Charnier.Pp 17130154ac8SAndrew MooreOne exception to the rule that addresses represent line numbers is the 17230154ac8SAndrew Mooreaddress 17300c2adfeSPhilippe Charnier.Em 0 17430154ac8SAndrew Moore(zero). 17530154ac8SAndrew MooreThis means "before the first line," 17630154ac8SAndrew Mooreand is legal wherever it makes sense. 17700c2adfeSPhilippe Charnier.Pp 17830154ac8SAndrew MooreAn address range is two addresses separated either by a comma or 179bef84d6bSSheldon Hearnsemi-colon. 180bef84d6bSSheldon HearnThe value of the first address in a range cannot exceed the 181e83201b4SWolfram Schneidervalue of the second. If only one address is given in a range, then 18295e6217eSAndrew Moorethe second address is set to the given address. If an 18300c2adfeSPhilippe Charnier.Em n Ns -tuple 18430154ac8SAndrew Mooreof addresses is given where 18500c2adfeSPhilippe Charnier.Em "n\ >\ 2" , 18695e6217eSAndrew Moorethen the corresponding range is determined by the last two addresses in 18795e6217eSAndrew Moorethe 18800c2adfeSPhilippe Charnier.Em n Ns -tuple. 18995e6217eSAndrew MooreIf only one address is expected, then the last address is used. 19000c2adfeSPhilippe Charnier.Pp 19130154ac8SAndrew MooreEach address in a comma-delimited range is interpreted relative to the 19230154ac8SAndrew Moorecurrent address. In a semi-colon-delimited range, the first address is 19330154ac8SAndrew Mooreused to set the current address, and the second address is interpreted 19430154ac8SAndrew Moorerelative to the first. 19500c2adfeSPhilippe Charnier.Pp 19600c2adfeSPhilippe CharnierThe following address symbols are recognized: 19700c2adfeSPhilippe Charnier.Bl -tag -width indent 19800c2adfeSPhilippe Charnier.It . 19930154ac8SAndrew MooreThe current line (address) in the buffer. 20000c2adfeSPhilippe Charnier.It $ 20130154ac8SAndrew MooreThe last line in the buffer. 20200c2adfeSPhilippe Charnier.It n 20330154ac8SAndrew MooreThe 20400c2adfeSPhilippe Charnier.Em n Ns th, 20530154ac8SAndrew Mooreline in the buffer 20630154ac8SAndrew Moorewhere 20700c2adfeSPhilippe Charnier.Em n 20830154ac8SAndrew Mooreis a number in the range 20900c2adfeSPhilippe Charnier.Em [0,$] . 21000c2adfeSPhilippe Charnier.It - or ^ 21130154ac8SAndrew MooreThe previous line. 21230154ac8SAndrew MooreThis is equivalent to 21300c2adfeSPhilippe Charnier.Em -1 21430154ac8SAndrew Mooreand may be repeated with cumulative effect. 21500c2adfeSPhilippe Charnier.It -n or ^n 21630154ac8SAndrew MooreThe 21700c2adfeSPhilippe Charnier.Em n Ns th 21830154ac8SAndrew Mooreprevious line, where 21900c2adfeSPhilippe Charnier.Em n 22030154ac8SAndrew Mooreis a non-negative number. 22100c2adfeSPhilippe Charnier.It + 22200c2adfeSPhilippe CharnierThe next line. 22330154ac8SAndrew MooreThis is equivalent to 22400c2adfeSPhilippe Charnier.Em +1 22530154ac8SAndrew Mooreand may be repeated with cumulative effect. 226056103b6SJoseph Koshy.It +n 22730154ac8SAndrew MooreThe 22800c2adfeSPhilippe Charnier.Em n Ns th 22930154ac8SAndrew Moorenext line, where 23000c2adfeSPhilippe Charnier.Em n 23130154ac8SAndrew Mooreis a non-negative number. 23200c2adfeSPhilippe Charnier.It , or % 23330154ac8SAndrew MooreThe first through last lines in the buffer. This is equivalent to 23430154ac8SAndrew Moorethe address range 23500c2adfeSPhilippe Charnier.Em 1,$ . 23600c2adfeSPhilippe Charnier.It ; 23700c2adfeSPhilippe CharnierThe current through last lines in the buffer. This is equivalent to 23830154ac8SAndrew Moorethe address range 23900c2adfeSPhilippe Charnier.Em .,$ . 24000c2adfeSPhilippe Charnier.It /re/ 24100c2adfeSPhilippe CharnierThe next line containing the regular expression 24200c2adfeSPhilippe Charnier.Em re . 24330154ac8SAndrew MooreThe search wraps to the beginning of the buffer and continues down to the 24430154ac8SAndrew Moorecurrent line, if necessary. 24530154ac8SAndrew Moore// repeats the last search. 24600c2adfeSPhilippe Charnier.It ?re? 24730154ac8SAndrew MooreThe 24830154ac8SAndrew Mooreprevious line containing the regular expression 24900c2adfeSPhilippe Charnier.Em re . 25030154ac8SAndrew MooreThe search wraps to the end of the buffer and continues up to the 25130154ac8SAndrew Moorecurrent line, if necessary. 25230154ac8SAndrew Moore?? repeats the last search. 25300c2adfeSPhilippe Charnier.It 'lc 25430154ac8SAndrew MooreThe 25530154ac8SAndrew Mooreline previously marked by a 25600c2adfeSPhilippe Charnier.Em k 25730154ac8SAndrew Moore(mark) command, where 25800c2adfeSPhilippe Charnier.Em lc 25930154ac8SAndrew Mooreis a lower case letter. 26000c2adfeSPhilippe Charnier.El 26100c2adfeSPhilippe Charnier.Sh REGULAR EXPRESSIONS 26230154ac8SAndrew MooreRegular expressions are patterns used in selecting text. 26300c2adfeSPhilippe CharnierFor example, the command: 26400c2adfeSPhilippe Charnier.Pp 26500c2adfeSPhilippe Charnier.Sm off 26600c2adfeSPhilippe Charnier.Cm g No / Em string Xo 26700c2adfeSPhilippe Charnier.No / 26800c2adfeSPhilippe Charnier.Xc 26900c2adfeSPhilippe Charnier.Sm on 27000c2adfeSPhilippe Charnier.Pp 27130154ac8SAndrew Mooreprints all lines containing 27200c2adfeSPhilippe Charnier.Em string . 27330154ac8SAndrew MooreRegular expressions are also 27430154ac8SAndrew Mooreused by the 27500c2adfeSPhilippe Charnier.Em s 27630154ac8SAndrew Moorecommand for selecting old text to be replaced with new. 27700c2adfeSPhilippe Charnier.Pp 27830154ac8SAndrew MooreIn addition to a specifying string literals, regular expressions can 27930154ac8SAndrew Moorerepresent 28030154ac8SAndrew Mooreclasses of strings. Strings thus represented are said to be matched 28130154ac8SAndrew Mooreby the corresponding regular expression. 28230154ac8SAndrew MooreIf it is possible for a regular expression 28330154ac8SAndrew Mooreto match several strings in a line, then the left-most longest match is 28430154ac8SAndrew Moorethe one selected. 28500c2adfeSPhilippe Charnier.Pp 28630154ac8SAndrew MooreThe following symbols are used in constructing regular expressions: 28700c2adfeSPhilippe Charnier.Bl -tag -width indent 28800c2adfeSPhilippe Charnier.It c 28930154ac8SAndrew MooreAny character 29000c2adfeSPhilippe Charnier.Em c 29130154ac8SAndrew Moorenot listed below, including `{', '}', `(', `)', `<' and `>', 29230154ac8SAndrew Moorematches itself. 29300c2adfeSPhilippe Charnier.It Pf \e c 29430154ac8SAndrew MooreAny backslash-escaped character 29500c2adfeSPhilippe Charnier.Em c , 29630154ac8SAndrew Mooreexcept for `{', '}', `(', `)', `<' and `>', 29730154ac8SAndrew Moorematches itself. 29800c2adfeSPhilippe Charnier.It . 29900c2adfeSPhilippe CharnierMatch any single character. 30000c2adfeSPhilippe Charnier.It Op char-class 30100c2adfeSPhilippe CharnierMatch any single character in 30200c2adfeSPhilippe Charnier.Em char-class . 30330154ac8SAndrew MooreTo include a `]' 30430154ac8SAndrew Moorein 30500c2adfeSPhilippe Charnier.Em char-class , 30630154ac8SAndrew Mooreit must be the first character. 30730154ac8SAndrew MooreA range of characters may be specified by separating the end characters 30830154ac8SAndrew Mooreof the range with a `-', e.g., `a-z' specifies the lower case characters. 30930154ac8SAndrew MooreThe following literal expressions can also be used in 31000c2adfeSPhilippe Charnier.Em char-class 31130154ac8SAndrew Mooreto specify sets of characters: 31200c2adfeSPhilippe Charnier.Pp 3131bdbdb45SRuslan Ermilov.Bl -column "[:alnum:]" "[:cntrl:]" "[:lower:]" "[:xdigit:]" -compact 3142b0a73baSRuslan Ermilov.It [:alnum:] Ta [:cntrl:] Ta [:lower:] Ta [:space:] 3152b0a73baSRuslan Ermilov.It [:alpha:] Ta [:digit:] Ta [:print:] Ta [:upper:] 3162b0a73baSRuslan Ermilov.It [:blank:] Ta [:graph:] Ta [:punct:] Ta [:xdigit:] 3172b0a73baSRuslan Ermilov.El 31800c2adfeSPhilippe Charnier.Pp 31930154ac8SAndrew MooreIf `-' appears as the first or last 32030154ac8SAndrew Moorecharacter of 32100c2adfeSPhilippe Charnier.Em char-class , 32230154ac8SAndrew Moorethen it matches itself. 32330154ac8SAndrew MooreAll other characters in 32400c2adfeSPhilippe Charnier.Em char-class 32530154ac8SAndrew Moorematch themselves. 32600c2adfeSPhilippe Charnier.Pp 32730154ac8SAndrew MoorePatterns in 328056103b6SJoseph Koshy.Em char-class 32930154ac8SAndrew Mooreof the form: 33000c2adfeSPhilippe Charnier.Pp 3312b0a73baSRuslan Ermilov.Bl -item -compact -offset 2n 3322b0a73baSRuslan Ermilov.It 3331586940eSRuslan Ermilov.Op \&. Ns Ar col-elm Ns .\& 3342b0a73baSRuslan Ermilovor, 3352b0a73baSRuslan Ermilov.It 3362b0a73baSRuslan Ermilov.Op = Ns Ar col-elm Ns = 3372b0a73baSRuslan Ermilov.El 33800c2adfeSPhilippe Charnier.Pp 33930154ac8SAndrew Moorewhere 3402b0a73baSRuslan Ermilov.Ar col-elm 34130154ac8SAndrew Mooreis a 34200c2adfeSPhilippe Charnier.Em collating element 34330154ac8SAndrew Mooreare interpreted according to 34400c2adfeSPhilippe Charnier.Xr locale 5 34530154ac8SAndrew Moore(not currently supported). 34630154ac8SAndrew MooreSee 34700c2adfeSPhilippe Charnier.Xr regex 3 34830154ac8SAndrew Moorefor an explanation of these constructs. 34900c2adfeSPhilippe Charnier.It Op ^char-class 35000c2adfeSPhilippe CharnierMatch any single character, other than newline, not in 35100c2adfeSPhilippe Charnier.Em char-class . 35200c2adfeSPhilippe Charnier.Em Char-class 35330154ac8SAndrew Mooreis defined 35430154ac8SAndrew Mooreas above. 35500c2adfeSPhilippe Charnier.It ^ 35600c2adfeSPhilippe CharnierIf 35700c2adfeSPhilippe Charnier.Em ^ 35800c2adfeSPhilippe Charnieris the first character of a regular expression, then it 35930154ac8SAndrew Mooreanchors the regular expression to the beginning of a line. 36030154ac8SAndrew MooreOtherwise, it matches itself. 36100c2adfeSPhilippe Charnier.It $ 36200c2adfeSPhilippe CharnierIf 36300c2adfeSPhilippe Charnier.Em $ 36400c2adfeSPhilippe Charnieris the last character of a regular expression, it 36530154ac8SAndrew Mooreanchors the regular expression to the end of a line. 36630154ac8SAndrew MooreOtherwise, it matches itself. 36700c2adfeSPhilippe Charnier.It Pf \e < 36800c2adfeSPhilippe CharnierAnchor the single character regular expression or subexpression 36930154ac8SAndrew Mooreimmediately following it to the beginning of a word. 37030154ac8SAndrew Moore(This may not be available) 37100c2adfeSPhilippe Charnier.It Pf \e > 37200c2adfeSPhilippe CharnierAnchor the single character regular expression or subexpression 37330154ac8SAndrew Mooreimmediately following it to the end of a word. 37430154ac8SAndrew Moore(This may not be available) 37500c2adfeSPhilippe Charnier.It Pf \e (re\e) 37600c2adfeSPhilippe CharnierDefine a subexpression 37700c2adfeSPhilippe Charnier.Em re . 37830154ac8SAndrew MooreSubexpressions may be nested. 37900c2adfeSPhilippe CharnierA subsequent backreference of the form 38000c2adfeSPhilippe Charnier.Em Pf \e n , 38100c2adfeSPhilippe Charnierwhere 38200c2adfeSPhilippe Charnier.Em n 38330154ac8SAndrew Mooreis a number in the range [1,9], expands to the text matched by the 38400c2adfeSPhilippe Charnier.Em n Ns th 38530154ac8SAndrew Mooresubexpression. 38610ca1c6cSAndrew MooreFor example, the regular expression `\e(.*\e)\e1' matches any string 38730154ac8SAndrew Mooreconsisting of identical adjacent substrings. 38830154ac8SAndrew MooreSubexpressions are ordered relative to 38930154ac8SAndrew Mooretheir left delimiter. 39000c2adfeSPhilippe Charnier.It * 39100c2adfeSPhilippe CharnierMatch the single character regular expression or subexpression 39200c2adfeSPhilippe Charnierimmediately preceding it zero or more times. If 39300c2adfeSPhilippe Charnier.Em * 39400c2adfeSPhilippe Charnieris the first 39530154ac8SAndrew Moorecharacter of a regular expression or subexpression, then it matches 39600c2adfeSPhilippe Charnieritself. The 39700c2adfeSPhilippe Charnier.Em * 39800c2adfeSPhilippe Charnieroperator sometimes yields unexpected results. 39930154ac8SAndrew MooreFor example, the regular expression `b*' matches the beginning of 40030154ac8SAndrew Moorethe string `abbb' (as opposed to the substring `bbb'), since a null match 40130154ac8SAndrew Mooreis the only left-most match. 40200c2adfeSPhilippe Charnier.It \e{n,m\e} or \e{n,\e} or \e{n\e} 40300c2adfeSPhilippe CharnierMatch the single character regular expression or subexpression 40430154ac8SAndrew Mooreimmediately preceding it at least 40500c2adfeSPhilippe Charnier.Em n 40630154ac8SAndrew Mooreand at most 40700c2adfeSPhilippe Charnier.Em m 40830154ac8SAndrew Mooretimes. 40930154ac8SAndrew MooreIf 41000c2adfeSPhilippe Charnier.Em m 41130154ac8SAndrew Mooreis omitted, then it matches at least 41200c2adfeSPhilippe Charnier.Em n 41330154ac8SAndrew Mooretimes. 41430154ac8SAndrew MooreIf the comma is also omitted, then it matches exactly 41500c2adfeSPhilippe Charnier.Em n 41630154ac8SAndrew Mooretimes. 41700c2adfeSPhilippe Charnier.El 41800c2adfeSPhilippe Charnier.Pp 41930154ac8SAndrew MooreAdditional regular expression operators may be defined depending on the 42030154ac8SAndrew Mooreparticular 42100c2adfeSPhilippe Charnier.Xr regex 3 42230154ac8SAndrew Mooreimplementation. 42300c2adfeSPhilippe Charnier.Sh COMMANDS 42430154ac8SAndrew MooreAll 42500c2adfeSPhilippe Charnier.Nm 426e3d79adaSJohn-Mark Gurneycommands are single characters, though some require additional parameters. 42730154ac8SAndrew MooreIf a command's parameters extend over several lines, then 42830154ac8SAndrew Mooreeach line except for the last 42930154ac8SAndrew Mooremust be terminated with a backslash (\\). 43012e720d7SRuslan Ermilov.Pp 43130154ac8SAndrew MooreIn general, at most one command is allowed per line. 43230154ac8SAndrew MooreHowever, most commands accept a print suffix, which is any of 43300c2adfeSPhilippe Charnier.Em p 43430154ac8SAndrew Moore(print), 43500c2adfeSPhilippe Charnier.Em l 43630154ac8SAndrew Moore(list) , 43730154ac8SAndrew Mooreor 43800c2adfeSPhilippe Charnier.Em n 43930154ac8SAndrew Moore(enumerate), 44030154ac8SAndrew Mooreto print the last line affected by the command. 44112e720d7SRuslan Ermilov.Pp 44230154ac8SAndrew MooreAn interrupt (typically ^C) has the effect of aborting the current command 44330154ac8SAndrew Mooreand returning the editor to command mode. 44412e720d7SRuslan Ermilov.Pp 44500c2adfeSPhilippe Charnier.Nm Ed 44630154ac8SAndrew Moorerecognizes the following commands. The commands are shown together with 44730154ac8SAndrew Moorethe default address or address range supplied if none is 44830154ac8SAndrew Moorespecified (in parenthesis). 44900c2adfeSPhilippe Charnier.Bl -tag -width indent 45000c2adfeSPhilippe Charnier.It (.)a 45100c2adfeSPhilippe CharnierAppend text to the buffer after the addressed line. 45230154ac8SAndrew MooreText is entered in input mode. 45330154ac8SAndrew MooreThe current address is set to last line entered. 45400c2adfeSPhilippe Charnier.It (.,.)c 45500c2adfeSPhilippe CharnierChange lines in the buffer. The addressed lines are deleted 45630154ac8SAndrew Moorefrom the buffer, and text is appended in their place. 45730154ac8SAndrew MooreText is entered in input mode. 45830154ac8SAndrew MooreThe current address is set to last line entered. 45900c2adfeSPhilippe Charnier.It (.,.)d 46000c2adfeSPhilippe CharnierDelete the addressed lines from the buffer. 46130154ac8SAndrew MooreIf there is a line after the deleted range, then the current address is set 462bef84d6bSSheldon Hearnto this line. 463bef84d6bSSheldon HearnOtherwise the current address is set to the line 46430154ac8SAndrew Moorebefore the deleted range. 46500c2adfeSPhilippe Charnier.It e Ar file 46600c2adfeSPhilippe CharnierEdit 46700c2adfeSPhilippe Charnier.Ar file , 46830154ac8SAndrew Mooreand sets the default filename. 46930154ac8SAndrew MooreIf 47000c2adfeSPhilippe Charnier.Ar file 47130154ac8SAndrew Mooreis not specified, then the default filename is used. 47230154ac8SAndrew MooreAny lines in the buffer are deleted before 47330154ac8SAndrew Moorethe new file is read. 47430154ac8SAndrew MooreThe current address is set to the last line read. 47500c2adfeSPhilippe Charnier.It e Ar !command 47600c2adfeSPhilippe CharnierEdit the standard output of 47700c2adfeSPhilippe Charnier.Ar !command , 47895e6217eSAndrew Moore(see 47900c2adfeSPhilippe Charnier.Ar !command 48095e6217eSAndrew Moorebelow). 48130154ac8SAndrew MooreThe default filename is unchanged. 48230154ac8SAndrew MooreAny lines in the buffer are deleted before the output of 48300c2adfeSPhilippe Charnier.Ar command 48430154ac8SAndrew Mooreis read. 48530154ac8SAndrew MooreThe current address is set to the last line read. 48600c2adfeSPhilippe Charnier.It E Ar file 48700c2adfeSPhilippe CharnierEdit 48800c2adfeSPhilippe Charnier.Ar file 48930154ac8SAndrew Mooreunconditionally. 49030154ac8SAndrew MooreThis is similar to the 49100c2adfeSPhilippe Charnier.Em e 49230154ac8SAndrew Moorecommand, 49330154ac8SAndrew Mooreexcept that unwritten changes are discarded without warning. 49430154ac8SAndrew MooreThe current address is set to the last line read. 49500c2adfeSPhilippe Charnier.It f Ar file 49600c2adfeSPhilippe CharnierSet the default filename to 49700c2adfeSPhilippe Charnier.Ar file . 49830154ac8SAndrew MooreIf 49900c2adfeSPhilippe Charnier.Ar file 50030154ac8SAndrew Mooreis not specified, then the default unescaped filename is printed. 50100c2adfeSPhilippe Charnier.It (1,$)g/re/command-list 50200c2adfeSPhilippe CharnierApply 50300c2adfeSPhilippe Charnier.Ar command-list 50430154ac8SAndrew Mooreto each of the addressed lines matching a regular expression 50500c2adfeSPhilippe Charnier.Ar re . 50630154ac8SAndrew MooreThe current address is set to the 50730154ac8SAndrew Mooreline currently matched before 50800c2adfeSPhilippe Charnier.Ar command-list 50930154ac8SAndrew Mooreis executed. 51030154ac8SAndrew MooreAt the end of the 51100c2adfeSPhilippe Charnier.Em g 51230154ac8SAndrew Moorecommand, the current address is set to the last line affected by 51300c2adfeSPhilippe Charnier.Ar command-list . 51400c2adfeSPhilippe Charnier.Pp 51530154ac8SAndrew MooreEach command in 51600c2adfeSPhilippe Charnier.Ar command-list 51730154ac8SAndrew Mooremust be on a separate line, 51830154ac8SAndrew Mooreand every line except for the last must be terminated by a backslash 51930154ac8SAndrew Moore(\\). 52030154ac8SAndrew MooreAny commands are allowed, except for 52100c2adfeSPhilippe Charnier.Em g , 52200c2adfeSPhilippe Charnier.Em G , 52300c2adfeSPhilippe Charnier.Em v , 52430154ac8SAndrew Mooreand 52500c2adfeSPhilippe Charnier.Em V . 52630154ac8SAndrew MooreA newline alone in 52700c2adfeSPhilippe Charnier.Ar command-list 52830154ac8SAndrew Mooreis equivalent to a 52900c2adfeSPhilippe Charnier.Em p 53030154ac8SAndrew Moorecommand. 53100c2adfeSPhilippe Charnier.It (1,$)G/re/ 53200c2adfeSPhilippe CharnierInteractively edit the addressed lines matching a regular expression 53300c2adfeSPhilippe Charnier.Ar re . 53430154ac8SAndrew MooreFor each matching line, 53530154ac8SAndrew Moorethe line is printed, 53630154ac8SAndrew Moorethe current address is set, 53730154ac8SAndrew Mooreand the user is prompted to enter a 53800c2adfeSPhilippe Charnier.Ar command-list . 53930154ac8SAndrew MooreAt the end of the 54000c2adfeSPhilippe Charnier.Em G 54130154ac8SAndrew Moorecommand, the current address 54230154ac8SAndrew Mooreis set to the last line affected by (the last) 54300c2adfeSPhilippe Charnier.Ar command-list . 54400c2adfeSPhilippe Charnier.Pp 54530154ac8SAndrew MooreThe format of 54600c2adfeSPhilippe Charnier.Ar command-list 54730154ac8SAndrew Mooreis the same as that of the 54800c2adfeSPhilippe Charnier.Em g 54930154ac8SAndrew Moorecommand. A newline alone acts as a null command list. 55030154ac8SAndrew MooreA single `&' repeats the last non-null command list. 55100c2adfeSPhilippe Charnier.It H 55200c2adfeSPhilippe CharnierToggle the printing of error explanations. 55330154ac8SAndrew MooreBy default, explanations are not printed. 55430154ac8SAndrew MooreIt is recommended that ed scripts begin with this command to 55530154ac8SAndrew Mooreaid in debugging. 55600c2adfeSPhilippe Charnier.It h 55700c2adfeSPhilippe CharnierPrint an explanation of the last error. 55800c2adfeSPhilippe Charnier.It (.)i 55900c2adfeSPhilippe CharnierInsert text in the buffer before the current line. 56030154ac8SAndrew MooreText is entered in input mode. 56130154ac8SAndrew MooreThe current address is set to the last line entered. 56200c2adfeSPhilippe Charnier.It (.,.+1)j 56300c2adfeSPhilippe CharnierJoin the addressed lines. The addressed lines are 56430154ac8SAndrew Mooredeleted from the buffer and replaced by a single 56530154ac8SAndrew Mooreline containing their joined text. 56630154ac8SAndrew MooreThe current address is set to the resultant line. 56700c2adfeSPhilippe Charnier.It (.)klc 56800c2adfeSPhilippe CharnierMark a line with a lower case letter 56900c2adfeSPhilippe Charnier.Em lc . 57030154ac8SAndrew MooreThe line can then be addressed as 57100c2adfeSPhilippe Charnier.Em 'lc 57230154ac8SAndrew Moore(i.e., a single quote followed by 57300c2adfeSPhilippe Charnier.Em lc 57430154ac8SAndrew Moore) in subsequent commands. The mark is not cleared until the line is 57530154ac8SAndrew Mooredeleted or otherwise modified. 57600c2adfeSPhilippe Charnier.It (.,.)l 57700c2adfeSPhilippe CharnierPrint the addressed lines unambiguously. 57895e6217eSAndrew MooreIf a single line fills for than one screen (as might be the case 57995e6217eSAndrew Moorewhen viewing a binary file, for instance), a `--More--' 58095e6217eSAndrew Mooreprompt is printed on the last line. 58100c2adfeSPhilippe Charnier.Nm Ed 58295e6217eSAndrew Moorewaits until the RETURN key is pressed 58395e6217eSAndrew Moorebefore displaying the next screen. 58430154ac8SAndrew MooreThe current address is set to the last line 58530154ac8SAndrew Mooreprinted. 58600c2adfeSPhilippe Charnier.It (.,.)m(.) 58700c2adfeSPhilippe CharnierMove lines in the buffer. The addressed lines are moved to after the 58830154ac8SAndrew Mooreright-hand destination address, which may be the address 58900c2adfeSPhilippe Charnier.Em 0 59030154ac8SAndrew Moore(zero). 59130154ac8SAndrew MooreThe current address is set to the 59230154ac8SAndrew Moorelast line moved. 59300c2adfeSPhilippe Charnier.It (.,.)n 59400c2adfeSPhilippe CharnierPrint the addressed lines along with 59530154ac8SAndrew Mooretheir line numbers. The current address is set to the last line 59630154ac8SAndrew Mooreprinted. 59700c2adfeSPhilippe Charnier.It (.,.)p 598bef84d6bSSheldon HearnPrint the addressed lines. 599bef84d6bSSheldon HearnThe current address is set to the last line 60030154ac8SAndrew Mooreprinted. 60100c2adfeSPhilippe Charnier.It P 60200c2adfeSPhilippe CharnierToggle the command prompt on and off. 60330154ac8SAndrew MooreUnless a prompt was specified by with command-line option 60400c2adfeSPhilippe Charnier.Fl p Ar string , 60500c2adfeSPhilippe Charnierthe command prompt is by default turned off. 60600c2adfeSPhilippe Charnier.It q 60700c2adfeSPhilippe CharnierQuit 608be8b1497SRuslan Ermilov.Nm . 60900c2adfeSPhilippe Charnier.It Q 61000c2adfeSPhilippe CharnierQuit 61100c2adfeSPhilippe Charnier.Nm 61200c2adfeSPhilippe Charnierunconditionally. 61330154ac8SAndrew MooreThis is similar to the 61400c2adfeSPhilippe Charnier.Em q 61530154ac8SAndrew Moorecommand, 61630154ac8SAndrew Mooreexcept that unwritten changes are discarded without warning. 61700c2adfeSPhilippe Charnier.It ($)r Ar file 61800c2adfeSPhilippe CharnierRead 61900c2adfeSPhilippe Charnier.Ar file 62030154ac8SAndrew Mooreto after the addressed line. If 62100c2adfeSPhilippe Charnier.Ar file 62230154ac8SAndrew Mooreis not specified, then the default 62330154ac8SAndrew Moorefilename is used. If there was no default filename prior to the command, 62430154ac8SAndrew Moorethen the default filename is set to 62500c2adfeSPhilippe Charnier.Ar file . 62630154ac8SAndrew MooreOtherwise, the default filename is unchanged. 62730154ac8SAndrew MooreThe current address is set to the last line read. 62800c2adfeSPhilippe Charnier.It ($)r Ar !command 62900c2adfeSPhilippe CharnierRead 63030154ac8SAndrew Mooreto after the addressed line 63130154ac8SAndrew Moorethe standard output of 63200c2adfeSPhilippe Charnier.Ar !command , 63395e6217eSAndrew Moore(see the 63400c2adfeSPhilippe Charnier.Ar !command 63595e6217eSAndrew Moorebelow). 63630154ac8SAndrew MooreThe default filename is unchanged. 63730154ac8SAndrew MooreThe current address is set to the last line read. 63800c2adfeSPhilippe Charnier.It (.,.)s/re/replacement/ 63900c2adfeSPhilippe Charnier.It (.,.)s/re/replacement/g 64000c2adfeSPhilippe Charnier.It (.,.)s/re/replacement/n 64100c2adfeSPhilippe CharnierReplace text in the addressed lines 64230154ac8SAndrew Moorematching a regular expression 64300c2adfeSPhilippe Charnier.Ar re 64430154ac8SAndrew Moorewith 64500c2adfeSPhilippe Charnier.Ar replacement . 64630154ac8SAndrew MooreBy default, only the first match in each line is replaced. 64795e6217eSAndrew MooreIf the 64800c2adfeSPhilippe Charnier.Em g 64995e6217eSAndrew Moore(global) suffix is given, then every match to be replaced. 65030154ac8SAndrew MooreThe 65100c2adfeSPhilippe Charnier.Em n 65230154ac8SAndrew Mooresuffix, where 65300c2adfeSPhilippe Charnier.Em n 65460fd953fSJordan K. Hubbardis a positive number, causes only the 65500c2adfeSPhilippe Charnier.Em n Ns th 65630154ac8SAndrew Moorematch to be replaced. 65730154ac8SAndrew MooreIt is an error if no substitutions are performed on any of the addressed 65830154ac8SAndrew Moorelines. 65930154ac8SAndrew MooreThe current address is set the last line affected. 66000c2adfeSPhilippe Charnier.Pp 66100c2adfeSPhilippe Charnier.Ar Re 66230154ac8SAndrew Mooreand 66300c2adfeSPhilippe Charnier.Ar replacement 66495e6217eSAndrew Mooremay be delimited by any character other than space and newline 66595e6217eSAndrew Moore(see the 66600c2adfeSPhilippe Charnier.Em s 66795e6217eSAndrew Moorecommand below). 66830154ac8SAndrew MooreIf one or two of the last delimiters is omitted, then the last line 66930154ac8SAndrew Mooreaffected is printed as though the print suffix 67000c2adfeSPhilippe Charnier.Em p 67130154ac8SAndrew Moorewere specified. 67200c2adfeSPhilippe Charnier.Pp 67330154ac8SAndrew MooreAn unescaped `&' in 67400c2adfeSPhilippe Charnier.Ar replacement 67530154ac8SAndrew Mooreis replaced by the currently matched text. 67630154ac8SAndrew MooreThe character sequence 67700c2adfeSPhilippe Charnier.Em \em , 67830154ac8SAndrew Moorewhere 67900c2adfeSPhilippe Charnier.Em m 68030154ac8SAndrew Mooreis a number in the range [1,9], is replaced by the 68100c2adfeSPhilippe Charnier.Em m th 68230154ac8SAndrew Moorebackreference expression of the matched text. 68330154ac8SAndrew MooreIf 68400c2adfeSPhilippe Charnier.Ar replacement 68530154ac8SAndrew Mooreconsists of a single `%', then 68600c2adfeSPhilippe Charnier.Ar replacement 68730154ac8SAndrew Moorefrom the last substitution is used. 68830154ac8SAndrew MooreNewlines may be embedded in 68900c2adfeSPhilippe Charnier.Ar replacement 69030154ac8SAndrew Mooreif they are escaped with a backslash (\\). 69100c2adfeSPhilippe Charnier.It (.,.)s 69200c2adfeSPhilippe CharnierRepeat the last substitution. 69330154ac8SAndrew MooreThis form of the 69400c2adfeSPhilippe Charnier.Em s 69595e6217eSAndrew Moorecommand accepts a count suffix 69600c2adfeSPhilippe Charnier.Em n , 69795e6217eSAndrew Mooreor any combination of the characters 69800c2adfeSPhilippe Charnier.Em r , 69900c2adfeSPhilippe Charnier.Em g , 70030154ac8SAndrew Mooreand 70100c2adfeSPhilippe Charnier.Em p . 70295e6217eSAndrew MooreIf a count suffix 70300c2adfeSPhilippe Charnier.Em n 70495e6217eSAndrew Mooreis given, then only the 70500c2adfeSPhilippe Charnier.Em n Ns th 70695e6217eSAndrew Moorematch is replaced. 70730154ac8SAndrew MooreThe 70800c2adfeSPhilippe Charnier.Em r 70930154ac8SAndrew Mooresuffix causes 71030154ac8SAndrew Moorethe regular expression of the last search to be used instead of the 71130154ac8SAndrew Moorethat of the last substitution. 71230154ac8SAndrew MooreThe 71300c2adfeSPhilippe Charnier.Em g 71430154ac8SAndrew Mooresuffix toggles the global suffix of the last substitution. 71530154ac8SAndrew MooreThe 71600c2adfeSPhilippe Charnier.Em p 71730154ac8SAndrew Mooresuffix toggles the print suffix of the last substitution 71830154ac8SAndrew MooreThe current address is set to the last line affected. 71900c2adfeSPhilippe Charnier.It (.,.)t(.) 72000c2adfeSPhilippe CharnierCopy (i.e., transfer) the addressed lines to after the right-hand 72130154ac8SAndrew Mooredestination address, which may be the address 72200c2adfeSPhilippe Charnier.Em 0 72330154ac8SAndrew Moore(zero). 72430154ac8SAndrew MooreThe current address is set to the last line 72530154ac8SAndrew Moorecopied. 72600c2adfeSPhilippe Charnier.It u 72700c2adfeSPhilippe CharnierUndo the last command and restores the current address 72830154ac8SAndrew Mooreto what it was before the command. 72930154ac8SAndrew MooreThe global commands 73000c2adfeSPhilippe Charnier.Em g , 73100c2adfeSPhilippe Charnier.Em G , 73200c2adfeSPhilippe Charnier.Em v , 73330154ac8SAndrew Mooreand 73400c2adfeSPhilippe Charnier.Em V . 73530154ac8SAndrew Mooreare treated as a single command by undo. 73600c2adfeSPhilippe Charnier.Em u 73730154ac8SAndrew Mooreis its own inverse. 73800c2adfeSPhilippe Charnier.It (1,$)v/re/command-list 73900c2adfeSPhilippe CharnierApply 74000c2adfeSPhilippe Charnier.Ar command-list 74130154ac8SAndrew Mooreto each of the addressed lines not matching a regular expression 74200c2adfeSPhilippe Charnier.Ar re . 74330154ac8SAndrew MooreThis is similar to the 74400c2adfeSPhilippe Charnier.Em g 74530154ac8SAndrew Moorecommand. 74600c2adfeSPhilippe Charnier.It (1,$)V/re/ 74700c2adfeSPhilippe CharnierInteractively edit the addressed lines not matching a regular expression 74800c2adfeSPhilippe Charnier.Ar re . 74930154ac8SAndrew MooreThis is similar to the 75000c2adfeSPhilippe Charnier.Em G 75130154ac8SAndrew Moorecommand. 75200c2adfeSPhilippe Charnier.It (1,$)w Ar file 75300c2adfeSPhilippe CharnierWrite the addressed lines to 75400c2adfeSPhilippe Charnier.Ar file . 75530154ac8SAndrew MooreAny previous contents of 75600c2adfeSPhilippe Charnier.Ar file 75730154ac8SAndrew Mooreis lost without warning. 75830154ac8SAndrew MooreIf there is no default filename, then the default filename is set to 75900c2adfeSPhilippe Charnier.Ar file , 76030154ac8SAndrew Mooreotherwise it is unchanged. If no filename is specified, then the default 76130154ac8SAndrew Moorefilename is used. 76230154ac8SAndrew MooreThe current address is unchanged. 76300c2adfeSPhilippe Charnier.It (1,$)wq Ar file 76400c2adfeSPhilippe CharnierWrite the addressed lines to 76500c2adfeSPhilippe Charnier.Ar file , 76630154ac8SAndrew Mooreand then executes a 76700c2adfeSPhilippe Charnier.Em q 76830154ac8SAndrew Moorecommand. 76900c2adfeSPhilippe Charnier.It (1,$)w Ar !command 77000c2adfeSPhilippe CharnierWrite the addressed lines to the standard input of 77100c2adfeSPhilippe Charnier.Ar !command , 77295e6217eSAndrew Moore(see the 77300c2adfeSPhilippe Charnier.Em !command 77495e6217eSAndrew Moorebelow). 77530154ac8SAndrew MooreThe default filename and current address are unchanged. 77600c2adfeSPhilippe Charnier.It (1,$)W Ar file 77700c2adfeSPhilippe CharnierAppend the addressed lines to the end of 77800c2adfeSPhilippe Charnier.Ar file . 77930154ac8SAndrew MooreThis is similar to the 78000c2adfeSPhilippe Charnier.Em w 78130154ac8SAndrew Moorecommand, expect that the previous contents of file is not clobbered. 78230154ac8SAndrew MooreThe current address is unchanged. 78300c2adfeSPhilippe Charnier.It x 78400c2adfeSPhilippe CharnierPrompt for an encryption key which is used in subsequent reads and 78530154ac8SAndrew Moorewrites. If a newline alone is entered as the key, then encryption is 78630154ac8SAndrew Mooreturned off. Otherwise, echoing is disabled while a key is read. 78700c2adfeSPhilippe CharnierEncryption/decryption is done using the 78800c2adfeSPhilippe Charnier.Xr bdes 1 78900c2adfeSPhilippe Charnieralgorithm. 79000c2adfeSPhilippe Charnier.It Pf (.+1)z n 79100c2adfeSPhilippe CharnierScroll 79200c2adfeSPhilippe Charnier.Ar n 79330154ac8SAndrew Moorelines at a time starting at addressed line. If 79400c2adfeSPhilippe Charnier.Ar n 79530154ac8SAndrew Mooreis not specified, then the current window size is used. 79630154ac8SAndrew MooreThe current address is set to the last line printed. 79700c2adfeSPhilippe Charnier.It !command 79800c2adfeSPhilippe CharnierExecute 79900c2adfeSPhilippe Charnier.Ar command 80030154ac8SAndrew Moorevia 80100c2adfeSPhilippe Charnier.Xr sh 1 . 80230154ac8SAndrew MooreIf the first character of 80300c2adfeSPhilippe Charnier.Ar command 80430154ac8SAndrew Mooreis `!', then it is replaced by text of the 80530154ac8SAndrew Mooreprevious 80600c2adfeSPhilippe Charnier.Ar !command . 80700c2adfeSPhilippe Charnier.Nm Ed 80830154ac8SAndrew Mooredoes not process 80900c2adfeSPhilippe Charnier.Ar command 81030154ac8SAndrew Moorefor backslash (\\) escapes. 81130154ac8SAndrew MooreHowever, an unescaped 81200c2adfeSPhilippe Charnier.Em % 81330154ac8SAndrew Mooreis replaced by the default filename. 81430154ac8SAndrew MooreWhen the shell returns from execution, a `!' 81530154ac8SAndrew Mooreis printed to the standard output. 81630154ac8SAndrew MooreThe current line is unchanged. 81700c2adfeSPhilippe Charnier.It ($)= 81800c2adfeSPhilippe CharnierPrint the line number of the addressed line. 81900c2adfeSPhilippe Charnier.It (.+1)newline 82000c2adfeSPhilippe CharnierPrint the addressed line, and sets the current address to 82130154ac8SAndrew Moorethat line. 82200c2adfeSPhilippe Charnier.El 82300c2adfeSPhilippe Charnier.Sh FILES 82400c2adfeSPhilippe Charnier.Bl -tag -width /tmp/ed.* -compact 82500c2adfeSPhilippe Charnier.It /tmp/ed.* 82600c2adfeSPhilippe Charnierbuffer file 82700c2adfeSPhilippe Charnier.It ed.hup 82800c2adfeSPhilippe Charnierthe file to which 82900c2adfeSPhilippe Charnier.Nm 83000c2adfeSPhilippe Charnierattempts to write the buffer if the terminal hangs up 83100c2adfeSPhilippe Charnier.El 83200c2adfeSPhilippe Charnier.Sh SEE ALSO 83300c2adfeSPhilippe Charnier.Xr bdes 1 , 83400c2adfeSPhilippe Charnier.Xr sed 1 , 83500c2adfeSPhilippe Charnier.Xr sh 1 , 83600c2adfeSPhilippe Charnier.Xr vi 1 , 83700c2adfeSPhilippe Charnier.Xr regex 3 83812e720d7SRuslan Ermilov.Pp 83930154ac8SAndrew MooreUSD:12-13 84000c2adfeSPhilippe Charnier.Rs 8410f5fcaa3SSheldon Hearn.%A B. W. Kernighan 8420f5fcaa3SSheldon Hearn.%A P. J. Plauger 84300c2adfeSPhilippe Charnier.%B Software Tools in Pascal 84400c2adfeSPhilippe Charnier.%O Addison-Wesley 84500c2adfeSPhilippe Charnier.%D 1981 84600c2adfeSPhilippe Charnier.Re 84700c2adfeSPhilippe Charnier.Sh LIMITATIONS 84800c2adfeSPhilippe Charnier.Nm Ed 84930154ac8SAndrew Mooreprocesses 85000c2adfeSPhilippe Charnier.Ar file 85130154ac8SAndrew Moorearguments for backslash escapes, i.e., in a filename, 85230154ac8SAndrew Mooreany characters preceded by a backslash (\\) are 85330154ac8SAndrew Mooreinterpreted literally. 85412e720d7SRuslan Ermilov.Pp 85530154ac8SAndrew MooreIf a text (non-binary) file is not terminated by a newline character, 85630154ac8SAndrew Moorethen 85700c2adfeSPhilippe Charnier.Nm 85830154ac8SAndrew Mooreappends one on reading/writing it. In the case of a binary file, 85900c2adfeSPhilippe Charnier.Nm 86030154ac8SAndrew Mooredoes not append a newline on reading/writing. 86112e720d7SRuslan Ermilov.Pp 86230154ac8SAndrew Mooreper line overhead: 4 ints 86300c2adfeSPhilippe Charnier.Sh DIAGNOSTICS 86430154ac8SAndrew MooreWhen an error occurs, 86500c2adfeSPhilippe Charnier.Nm 86630154ac8SAndrew Mooreprints a `?' and either returns to command mode 86730154ac8SAndrew Mooreor exits if its input is from a script. 86830154ac8SAndrew MooreAn explanation of the last error can be 86930154ac8SAndrew Mooreprinted with the 87000c2adfeSPhilippe Charnier.Em h 87130154ac8SAndrew Moore(help) command. 87212e720d7SRuslan Ermilov.Pp 87330154ac8SAndrew MooreSince the 87400c2adfeSPhilippe Charnier.Em g 87530154ac8SAndrew Moore(global) command masks any errors from failed searches and substitutions, 87630154ac8SAndrew Mooreit can be used to perform conditional operations in scripts; e.g., 87700c2adfeSPhilippe Charnier.Pp 87800c2adfeSPhilippe Charnier.Sm off 87900c2adfeSPhilippe Charnier.Cm g No / Em old Xo 88000c2adfeSPhilippe Charnier.No / Cm s 88100c2adfeSPhilippe Charnier.No // Em new 88200c2adfeSPhilippe Charnier.No / 88300c2adfeSPhilippe Charnier.Xc 88400c2adfeSPhilippe Charnier.Sm on 88500c2adfeSPhilippe Charnier.Pp 88630154ac8SAndrew Moorereplaces any occurrences of 88700c2adfeSPhilippe Charnier.Em old 88830154ac8SAndrew Moorewith 88900c2adfeSPhilippe Charnier.Em new . 89010ca1c6cSAndrew MooreIf the 89100c2adfeSPhilippe Charnier.Em u 89210ca1c6cSAndrew Moore(undo) command occurs in a global command list, then 89310ca1c6cSAndrew Moorethe command list is executed only once. 89412e720d7SRuslan Ermilov.Pp 89530154ac8SAndrew MooreIf diagnostics are not disabled, attempting to quit 89600c2adfeSPhilippe Charnier.Nm 89730154ac8SAndrew Mooreor edit another file before writing a modified buffer 89830154ac8SAndrew Mooreresults in an error. 89930154ac8SAndrew MooreIf the command is entered a second time, it succeeds, 90030154ac8SAndrew Moorebut any changes to the buffer are lost. 90100c2adfeSPhilippe Charnier.Sh HISTORY 902b8923d4cSWolfram SchneiderA 90300c2adfeSPhilippe Charnier.Nm 904b8923d4cSWolfram Schneidercommand appeared in 905b8923d4cSWolfram SchneiderVersion 1 AT&T UNIX. 906