1056103b6SJoseph Koshy.\" $Id: ed.1,v 1.13 1998/05/13 07:41:13 charnier Exp $ 200c2adfeSPhilippe Charnier.Dd May 21, 1993 300c2adfeSPhilippe Charnier.Dt ED 1 400c2adfeSPhilippe Charnier.Os 500c2adfeSPhilippe Charnier.Sh NAME 6d165d4acSAndrew Moore.\" ed, red \- text editor 700c2adfeSPhilippe Charnier.Nm ed 800c2adfeSPhilippe Charnier.Nd text editor 900c2adfeSPhilippe Charnier.Sh SYNOPSIS 1000c2adfeSPhilippe Charnier.Nm ed 1100c2adfeSPhilippe Charnier.Op Fl 1200c2adfeSPhilippe Charnier.Op Fl sx 1300c2adfeSPhilippe Charnier.Op Fl p Ar string 1400c2adfeSPhilippe Charnier.Op Ar file 15d165d4acSAndrew Moore.\" .LP 16d165d4acSAndrew Moore.\" red [-] [-sx] [-p \fIstring\fR] [\fIfile\fR] 1700c2adfeSPhilippe Charnier.Sh DESCRIPTION 1800c2adfeSPhilippe Charnier.Nm Ed 1930154ac8SAndrew Mooreis a line-oriented text editor. 2030154ac8SAndrew MooreIt is used to create, display, modify and otherwise manipulate text 2130154ac8SAndrew Moorefiles. 22d165d4acSAndrew Moore.\" .B red 23d165d4acSAndrew Moore.\" is a restricted 24d165d4acSAndrew Moore.\" .BR ed : 25d165d4acSAndrew Moore.\" it can only edit files in the current 26d165d4acSAndrew Moore.\" directory and cannot execute shell commands. 2730154ac8SAndrew Moore 2830154ac8SAndrew MooreIf invoked with a 2900c2adfeSPhilippe Charnier.Ar file 3030154ac8SAndrew Mooreargument, then a copy of 3100c2adfeSPhilippe Charnier.Ar file 3230154ac8SAndrew Mooreis read into the editor's buffer. 3330154ac8SAndrew MooreChanges are made to this copy and not directly to 3400c2adfeSPhilippe Charnier.Ar file 3530154ac8SAndrew Mooreitself. 3630154ac8SAndrew MooreUpon quitting 3700c2adfeSPhilippe Charnier.Nm Ns , 3830154ac8SAndrew Mooreany changes not explicitly saved with a 3900c2adfeSPhilippe Charnier.Em w 4030154ac8SAndrew Moorecommand are lost. 4130154ac8SAndrew Moore 4230154ac8SAndrew MooreEditing is done in two distinct modes: 4300c2adfeSPhilippe Charnier.Em command 4430154ac8SAndrew Mooreand 4500c2adfeSPhilippe Charnier.Em input . 4630154ac8SAndrew MooreWhen first invoked, 4700c2adfeSPhilippe Charnier.Nm 4830154ac8SAndrew Mooreis in command mode. 4930154ac8SAndrew MooreIn this mode commands are read from the standard input and 5030154ac8SAndrew Mooreexecuted to manipulate the contents of the editor buffer. 5130154ac8SAndrew MooreA typical command might look like: 5200c2adfeSPhilippe Charnier.Pp 5300c2adfeSPhilippe Charnier.Sm off 5400c2adfeSPhilippe Charnier.Cm ,s No / Em old Xo 5500c2adfeSPhilippe Charnier.No / Em new 5600c2adfeSPhilippe Charnier.No / Cm g 5700c2adfeSPhilippe Charnier.Xc 5800c2adfeSPhilippe Charnier.Sm on 5900c2adfeSPhilippe Charnier.Pp 6060fd953fSJordan K. Hubbardwhich replaces all occurrences of the string 6100c2adfeSPhilippe Charnier.Em old 6230154ac8SAndrew Moorewith 6300c2adfeSPhilippe Charnier.Em new . 6400c2adfeSPhilippe Charnier.Pp 6530154ac8SAndrew MooreWhen an input command, such as 6600c2adfeSPhilippe Charnier.Em a 6730154ac8SAndrew Moore(append), 6800c2adfeSPhilippe Charnier.Em i 6930154ac8SAndrew Moore(insert) or 7000c2adfeSPhilippe Charnier.Em c 7130154ac8SAndrew Moore(change), is given, 7200c2adfeSPhilippe Charnier.Nm 7330154ac8SAndrew Mooreenters input mode. This is the primary means 7430154ac8SAndrew Mooreof adding text to a file. 7530154ac8SAndrew MooreIn this mode, no commands are available; 7630154ac8SAndrew Mooreinstead, the standard input is written 7730154ac8SAndrew Mooredirectly to the editor buffer. Lines consist of text up to and 7830154ac8SAndrew Mooreincluding a 7900c2adfeSPhilippe Charnier.Em newline 8030154ac8SAndrew Moorecharacter. 8130154ac8SAndrew MooreInput mode is terminated by 8200c2adfeSPhilippe Charnierentering a single period 8300c2adfeSPhilippe Charnier.Pf ( Em . Ns ) 8400c2adfeSPhilippe Charnieron a line. 8500c2adfeSPhilippe Charnier.Pp 8630154ac8SAndrew MooreAll 8700c2adfeSPhilippe Charnier.Nm 8830154ac8SAndrew Moorecommands operate on whole lines or ranges of lines; e.g., 8930154ac8SAndrew Moorethe 9000c2adfeSPhilippe Charnier.Em d 9130154ac8SAndrew Moorecommand deletes lines; the 9200c2adfeSPhilippe Charnier.Em m 9330154ac8SAndrew Moorecommand moves lines, and so on. 9430154ac8SAndrew MooreIt is possible to modify only a portion of a line by means of replacement, 9530154ac8SAndrew Mooreas in the example above. However even here, the 9600c2adfeSPhilippe Charnier.Em s 9730154ac8SAndrew Moorecommand is applied to whole lines at a time. 9800c2adfeSPhilippe Charnier.Pp 9930154ac8SAndrew MooreIn general, 10000c2adfeSPhilippe Charnier.Nm 10130154ac8SAndrew Moorecommands consist of zero or more line addresses, followed by a single 10230154ac8SAndrew Moorecharacter command and possibly additional parameters; i.e., 10330154ac8SAndrew Moorecommands have the structure: 10400c2adfeSPhilippe Charnier.Pp 10500c2adfeSPhilippe Charnier.Sm off 10600c2adfeSPhilippe Charnier.Xo Op "address\ " Op ,address 10700c2adfeSPhilippe Charnier.No command Op parameters 10800c2adfeSPhilippe Charnier.Xc 10900c2adfeSPhilippe Charnier.Sm on 11000c2adfeSPhilippe Charnier.Pp 11110ca1c6cSAndrew MooreThe address(es) indicate the line or range of lines to be affected by the 11210ca1c6cSAndrew Moorecommand. If fewer addresses are given than the command accepts, then 11310ca1c6cSAndrew Mooredefault addresses are supplied. 11400c2adfeSPhilippe Charnier.Sh OPTIONS 11500c2adfeSPhilippe CharnierThe following options are available: 11600c2adfeSPhilippe Charnier.Bl -tag -width indent 11700c2adfeSPhilippe Charnier.It Fl s 11800c2adfeSPhilippe CharnierSuppress diagnostics. This should be used if 11900c2adfeSPhilippe Charnier.Nm Ns 's 12030154ac8SAndrew Moorestandard input is from a script. 12100c2adfeSPhilippe Charnier.It Fl x 12200c2adfeSPhilippe CharnierPrompt for an encryption key to be used in subsequent reads and writes 12330154ac8SAndrew Moore(see the 12400c2adfeSPhilippe Charnier.Em x 12530154ac8SAndrew Moorecommand). 12600c2adfeSPhilippe Charnier.It Fl p Ar string 12700c2adfeSPhilippe CharnierSpecify a command prompt. This may be toggled on and off with the 12800c2adfeSPhilippe Charnier.Em P 12930154ac8SAndrew Moorecommand. 13000c2adfeSPhilippe Charnier.It Ar file 13100c2adfeSPhilippe CharnierSpecify the name of a file to read. If 13200c2adfeSPhilippe Charnier.Ar file 13330154ac8SAndrew Mooreis prefixed with a 13430154ac8SAndrew Moorebang (!), then it is interpreted as a shell command. In this case, 13530154ac8SAndrew Moorewhat is read is 13630154ac8SAndrew Moorethe standard output of 13700c2adfeSPhilippe Charnier.Ar file 13830154ac8SAndrew Mooreexecuted via 13900c2adfeSPhilippe Charnier.Xr sh 1 . 14030154ac8SAndrew MooreTo read a file whose name begins with a bang, prefix the 14130154ac8SAndrew Moorename with a backslash (\\). 14230154ac8SAndrew MooreThe default filename is set to 14300c2adfeSPhilippe Charnier.Ar file 14430154ac8SAndrew Mooreonly if it is not prefixed with a bang. 14500c2adfeSPhilippe Charnier.El 14600c2adfeSPhilippe Charnier.Sh LINE ADDRESSING 14795e6217eSAndrew MooreAn address represents the number of a line in the buffer. 14800c2adfeSPhilippe Charnier.Nm Ed 14930154ac8SAndrew Mooremaintains a 15000c2adfeSPhilippe Charnier.Em current address 15130154ac8SAndrew Moorewhich is 15230154ac8SAndrew Mooretypically supplied to commands as the default address when none is specified. 15330154ac8SAndrew MooreWhen a file is first read, the current address is set to the last line 15430154ac8SAndrew Mooreof the file. In general, the current address is set to the last line 15530154ac8SAndrew Mooreaffected by a command. 15600c2adfeSPhilippe Charnier.Pp 15730154ac8SAndrew MooreA line address is 15830154ac8SAndrew Mooreconstructed from one of the bases in the list below, optionally followed 15930154ac8SAndrew Mooreby a numeric offset. The offset may include any combination 16030154ac8SAndrew Mooreof digits, operators (i.e., 16100c2adfeSPhilippe Charnier.Em + , 16200c2adfeSPhilippe Charnier.Em - 16330154ac8SAndrew Mooreand 16400c2adfeSPhilippe Charnier.Em ^ ) 16530154ac8SAndrew Mooreand whitespace. 16630154ac8SAndrew MooreAddresses are read from left to right, and their values are computed 16730154ac8SAndrew Moorerelative to the current address. 16800c2adfeSPhilippe Charnier.Pp 16930154ac8SAndrew MooreOne exception to the rule that addresses represent line numbers is the 17030154ac8SAndrew Mooreaddress 17100c2adfeSPhilippe Charnier.Em 0 17230154ac8SAndrew Moore(zero). 17330154ac8SAndrew MooreThis means "before the first line," 17430154ac8SAndrew Mooreand is legal wherever it makes sense. 17500c2adfeSPhilippe Charnier.Pp 17630154ac8SAndrew MooreAn address range is two addresses separated either by a comma or 17730154ac8SAndrew Mooresemi-colon. The value of the first address in a range cannot exceed the 178e83201b4SWolfram Schneidervalue of the second. If only one address is given in a range, then 17995e6217eSAndrew Moorethe second address is set to the given address. If an 18000c2adfeSPhilippe Charnier.Em n Ns -tuple 18130154ac8SAndrew Mooreof addresses is given where 18200c2adfeSPhilippe Charnier.Em "n\ >\ 2" , 18395e6217eSAndrew Moorethen the corresponding range is determined by the last two addresses in 18495e6217eSAndrew Moorethe 18500c2adfeSPhilippe Charnier.Em n Ns -tuple. 18695e6217eSAndrew MooreIf only one address is expected, then the last address is used. 18700c2adfeSPhilippe Charnier.Pp 18830154ac8SAndrew MooreEach address in a comma-delimited range is interpreted relative to the 18930154ac8SAndrew Moorecurrent address. In a semi-colon-delimited range, the first address is 19030154ac8SAndrew Mooreused to set the current address, and the second address is interpreted 19130154ac8SAndrew Moorerelative to the first. 19200c2adfeSPhilippe Charnier.Pp 19300c2adfeSPhilippe CharnierThe following address symbols are recognized: 19400c2adfeSPhilippe Charnier.Bl -tag -width indent 19500c2adfeSPhilippe Charnier.It . 19630154ac8SAndrew MooreThe current line (address) in the buffer. 19700c2adfeSPhilippe Charnier.It $ 19830154ac8SAndrew MooreThe last line in the buffer. 19900c2adfeSPhilippe Charnier.It n 20030154ac8SAndrew MooreThe 20100c2adfeSPhilippe Charnier.Em n Ns th, 20230154ac8SAndrew Mooreline in the buffer 20330154ac8SAndrew Moorewhere 20400c2adfeSPhilippe Charnier.Em n 20530154ac8SAndrew Mooreis a number in the range 20600c2adfeSPhilippe Charnier.Em [0,$] . 20700c2adfeSPhilippe Charnier.It - or ^ 20830154ac8SAndrew MooreThe previous line. 20930154ac8SAndrew MooreThis is equivalent to 21000c2adfeSPhilippe Charnier.Em -1 21130154ac8SAndrew Mooreand may be repeated with cumulative effect. 21200c2adfeSPhilippe Charnier.It -n or ^n 21330154ac8SAndrew MooreThe 21400c2adfeSPhilippe Charnier.Em n Ns th 21530154ac8SAndrew Mooreprevious line, where 21600c2adfeSPhilippe Charnier.Em n 21730154ac8SAndrew Mooreis a non-negative number. 21800c2adfeSPhilippe Charnier.It + 21900c2adfeSPhilippe CharnierThe next line. 22030154ac8SAndrew MooreThis is equivalent to 22100c2adfeSPhilippe Charnier.Em +1 22230154ac8SAndrew Mooreand may be repeated with cumulative effect. 223056103b6SJoseph Koshy.It +n 22430154ac8SAndrew MooreThe 22500c2adfeSPhilippe Charnier.Em n Ns th 22630154ac8SAndrew Moorenext line, where 22700c2adfeSPhilippe Charnier.Em n 22830154ac8SAndrew Mooreis a non-negative number. 22900c2adfeSPhilippe Charnier.It , or % 23030154ac8SAndrew MooreThe first through last lines in the buffer. This is equivalent to 23130154ac8SAndrew Moorethe address range 23200c2adfeSPhilippe Charnier.Em 1,$ . 23300c2adfeSPhilippe Charnier.It ; 23400c2adfeSPhilippe CharnierThe current through last lines in the buffer. This is equivalent to 23530154ac8SAndrew Moorethe address range 23600c2adfeSPhilippe Charnier.Em .,$ . 23700c2adfeSPhilippe Charnier.It /re/ 23800c2adfeSPhilippe CharnierThe next line containing the regular expression 23900c2adfeSPhilippe Charnier.Em re . 24030154ac8SAndrew MooreThe search wraps to the beginning of the buffer and continues down to the 24130154ac8SAndrew Moorecurrent line, if necessary. 24230154ac8SAndrew Moore// repeats the last search. 24300c2adfeSPhilippe Charnier.It ?re? 24430154ac8SAndrew MooreThe 24530154ac8SAndrew Mooreprevious line containing the regular expression 24600c2adfeSPhilippe Charnier.Em re . 24730154ac8SAndrew MooreThe search wraps to the end of the buffer and continues up to the 24830154ac8SAndrew Moorecurrent line, if necessary. 24930154ac8SAndrew Moore?? repeats the last search. 25000c2adfeSPhilippe Charnier.It 'lc 25130154ac8SAndrew MooreThe 25230154ac8SAndrew Mooreline previously marked by a 25300c2adfeSPhilippe Charnier.Em k 25430154ac8SAndrew Moore(mark) command, where 25500c2adfeSPhilippe Charnier.Em lc 25630154ac8SAndrew Mooreis a lower case letter. 25700c2adfeSPhilippe Charnier.El 25800c2adfeSPhilippe Charnier.Sh REGULAR EXPRESSIONS 25930154ac8SAndrew MooreRegular expressions are patterns used in selecting text. 26000c2adfeSPhilippe CharnierFor example, the command: 26100c2adfeSPhilippe Charnier.Pp 26200c2adfeSPhilippe Charnier.Sm off 26300c2adfeSPhilippe Charnier.Cm g No / Em string Xo 26400c2adfeSPhilippe Charnier.No / 26500c2adfeSPhilippe Charnier.Xc 26600c2adfeSPhilippe Charnier.Sm on 26700c2adfeSPhilippe Charnier.Pp 26830154ac8SAndrew Mooreprints all lines containing 26900c2adfeSPhilippe Charnier.Em string . 27030154ac8SAndrew MooreRegular expressions are also 27130154ac8SAndrew Mooreused by the 27200c2adfeSPhilippe Charnier.Em s 27330154ac8SAndrew Moorecommand for selecting old text to be replaced with new. 27400c2adfeSPhilippe Charnier.Pp 27530154ac8SAndrew MooreIn addition to a specifying string literals, regular expressions can 27630154ac8SAndrew Moorerepresent 27730154ac8SAndrew Mooreclasses of strings. Strings thus represented are said to be matched 27830154ac8SAndrew Mooreby the corresponding regular expression. 27930154ac8SAndrew MooreIf it is possible for a regular expression 28030154ac8SAndrew Mooreto match several strings in a line, then the left-most longest match is 28130154ac8SAndrew Moorethe one selected. 28200c2adfeSPhilippe Charnier.Pp 28330154ac8SAndrew MooreThe following symbols are used in constructing regular expressions: 28400c2adfeSPhilippe Charnier.Bl -tag -width indent 28500c2adfeSPhilippe Charnier.It c 28630154ac8SAndrew MooreAny character 28700c2adfeSPhilippe Charnier.Em c 28830154ac8SAndrew Moorenot listed below, including `{', '}', `(', `)', `<' and `>', 28930154ac8SAndrew Moorematches itself. 29000c2adfeSPhilippe Charnier.It Pf \e c 29130154ac8SAndrew MooreAny backslash-escaped character 29200c2adfeSPhilippe Charnier.Em c , 29330154ac8SAndrew Mooreexcept for `{', '}', `(', `)', `<' and `>', 29430154ac8SAndrew Moorematches itself. 29500c2adfeSPhilippe Charnier.It . 29600c2adfeSPhilippe CharnierMatch any single character. 29700c2adfeSPhilippe Charnier.It Op char-class 29800c2adfeSPhilippe CharnierMatch any single character in 29900c2adfeSPhilippe Charnier.Em char-class . 30030154ac8SAndrew MooreTo include a `]' 30130154ac8SAndrew Moorein 30200c2adfeSPhilippe Charnier.Em char-class , 30330154ac8SAndrew Mooreit must be the first character. 30430154ac8SAndrew MooreA range of characters may be specified by separating the end characters 30530154ac8SAndrew Mooreof the range with a `-', e.g., `a-z' specifies the lower case characters. 30630154ac8SAndrew MooreThe following literal expressions can also be used in 30700c2adfeSPhilippe Charnier.Em char-class 30830154ac8SAndrew Mooreto specify sets of characters: 30900c2adfeSPhilippe Charnier.Pp 31030154ac8SAndrew Moore\ \ [:alnum:]\ \ [:cntrl:]\ \ [:lower:]\ \ [:space:] 31130154ac8SAndrew Moore.PD 0 31230154ac8SAndrew Moore\ \ [:alpha:]\ \ [:digit:]\ \ [:print:]\ \ [:upper:] 31330154ac8SAndrew Moore.PD 0 31430154ac8SAndrew Moore\ \ [:blank:]\ \ [:graph:]\ \ [:punct:]\ \ [:xdigit:] 31500c2adfeSPhilippe Charnier.Pp 31630154ac8SAndrew MooreIf `-' appears as the first or last 31730154ac8SAndrew Moorecharacter of 31800c2adfeSPhilippe Charnier.Em char-class , 31930154ac8SAndrew Moorethen it matches itself. 32030154ac8SAndrew MooreAll other characters in 32100c2adfeSPhilippe Charnier.Em char-class 32230154ac8SAndrew Moorematch themselves. 32300c2adfeSPhilippe Charnier.Pp 32430154ac8SAndrew MoorePatterns in 325056103b6SJoseph Koshy.Em char-class 32630154ac8SAndrew Mooreof the form: 32700c2adfeSPhilippe Charnier.Pp 32830154ac8SAndrew Moore\ \ [.\fIcol-elm\fR.] or, 32930154ac8SAndrew Moore.PD 0 33030154ac8SAndrew Moore\ \ [=\fIcol-elm\fR=] 33100c2adfeSPhilippe Charnier.Pp 33230154ac8SAndrew Moorewhere 33300c2adfeSPhilippe Charnier.Em col-elm 33430154ac8SAndrew Mooreis a 33500c2adfeSPhilippe Charnier.Em collating element 33630154ac8SAndrew Mooreare interpreted according to 33700c2adfeSPhilippe Charnier.Xr locale 5 33830154ac8SAndrew Moore(not currently supported). 33930154ac8SAndrew MooreSee 34000c2adfeSPhilippe Charnier.Xr regex 3 34130154ac8SAndrew Moorefor an explanation of these constructs. 34200c2adfeSPhilippe Charnier.It Op ^char-class 34300c2adfeSPhilippe CharnierMatch any single character, other than newline, not in 34400c2adfeSPhilippe Charnier.Em char-class . 34500c2adfeSPhilippe Charnier.Em Char-class 34630154ac8SAndrew Mooreis defined 34730154ac8SAndrew Mooreas above. 34800c2adfeSPhilippe Charnier.It ^ 34900c2adfeSPhilippe CharnierIf 35000c2adfeSPhilippe Charnier.Em ^ 35100c2adfeSPhilippe Charnieris the first character of a regular expression, then it 35230154ac8SAndrew Mooreanchors the regular expression to the beginning of a line. 35330154ac8SAndrew MooreOtherwise, it matches itself. 35400c2adfeSPhilippe Charnier.It $ 35500c2adfeSPhilippe CharnierIf 35600c2adfeSPhilippe Charnier.Em $ 35700c2adfeSPhilippe Charnieris the last character of a regular expression, it 35830154ac8SAndrew Mooreanchors the regular expression to the end of a line. 35930154ac8SAndrew MooreOtherwise, it matches itself. 36000c2adfeSPhilippe Charnier.It Pf \e < 36100c2adfeSPhilippe CharnierAnchor the single character regular expression or subexpression 36230154ac8SAndrew Mooreimmediately following it to the beginning of a word. 36330154ac8SAndrew Moore(This may not be available) 36400c2adfeSPhilippe Charnier.It Pf \e > 36500c2adfeSPhilippe CharnierAnchor the single character regular expression or subexpression 36630154ac8SAndrew Mooreimmediately following it to the end of a word. 36730154ac8SAndrew Moore(This may not be available) 36800c2adfeSPhilippe Charnier.It Pf \e (re\e) 36900c2adfeSPhilippe CharnierDefine a subexpression 37000c2adfeSPhilippe Charnier.Em re . 37130154ac8SAndrew MooreSubexpressions may be nested. 37200c2adfeSPhilippe CharnierA subsequent backreference of the form 37300c2adfeSPhilippe Charnier.Em Pf \e n , 37400c2adfeSPhilippe Charnierwhere 37500c2adfeSPhilippe Charnier.Em n 37630154ac8SAndrew Mooreis a number in the range [1,9], expands to the text matched by the 37700c2adfeSPhilippe Charnier.Em n Ns th 37830154ac8SAndrew Mooresubexpression. 37910ca1c6cSAndrew MooreFor example, the regular expression `\e(.*\e)\e1' matches any string 38030154ac8SAndrew Mooreconsisting of identical adjacent substrings. 38130154ac8SAndrew MooreSubexpressions are ordered relative to 38230154ac8SAndrew Mooretheir left delimiter. 38300c2adfeSPhilippe Charnier.It * 38400c2adfeSPhilippe CharnierMatch the single character regular expression or subexpression 38500c2adfeSPhilippe Charnierimmediately preceding it zero or more times. If 38600c2adfeSPhilippe Charnier.Em * 38700c2adfeSPhilippe Charnieris the first 38830154ac8SAndrew Moorecharacter of a regular expression or subexpression, then it matches 38900c2adfeSPhilippe Charnieritself. The 39000c2adfeSPhilippe Charnier.Em * 39100c2adfeSPhilippe Charnieroperator sometimes yields unexpected results. 39230154ac8SAndrew MooreFor example, the regular expression `b*' matches the beginning of 39330154ac8SAndrew Moorethe string `abbb' (as opposed to the substring `bbb'), since a null match 39430154ac8SAndrew Mooreis the only left-most match. 39500c2adfeSPhilippe Charnier.It \e{n,m\e} or \e{n,\e} or \e{n\e} 39600c2adfeSPhilippe CharnierMatch the single character regular expression or subexpression 39730154ac8SAndrew Mooreimmediately preceding it at least 39800c2adfeSPhilippe Charnier.Em n 39930154ac8SAndrew Mooreand at most 40000c2adfeSPhilippe Charnier.Em m 40130154ac8SAndrew Mooretimes. 40230154ac8SAndrew MooreIf 40300c2adfeSPhilippe Charnier.Em m 40430154ac8SAndrew Mooreis omitted, then it matches at least 40500c2adfeSPhilippe Charnier.Em n 40630154ac8SAndrew Mooretimes. 40730154ac8SAndrew MooreIf the comma is also omitted, then it matches exactly 40800c2adfeSPhilippe Charnier.Em n 40930154ac8SAndrew Mooretimes. 41000c2adfeSPhilippe Charnier.El 41100c2adfeSPhilippe Charnier.Pp 41230154ac8SAndrew MooreAdditional regular expression operators may be defined depending on the 41330154ac8SAndrew Mooreparticular 41400c2adfeSPhilippe Charnier.Xr regex 3 41530154ac8SAndrew Mooreimplementation. 41600c2adfeSPhilippe Charnier.Sh COMMANDS 41730154ac8SAndrew MooreAll 41800c2adfeSPhilippe Charnier.Nm 419e3d79adaSJohn-Mark Gurneycommands are single characters, though some require additional parameters. 42030154ac8SAndrew MooreIf a command's parameters extend over several lines, then 42130154ac8SAndrew Mooreeach line except for the last 42230154ac8SAndrew Mooremust be terminated with a backslash (\\). 42330154ac8SAndrew Moore 42430154ac8SAndrew MooreIn general, at most one command is allowed per line. 42530154ac8SAndrew MooreHowever, most commands accept a print suffix, which is any of 42600c2adfeSPhilippe Charnier.Em p 42730154ac8SAndrew Moore(print), 42800c2adfeSPhilippe Charnier.Em l 42930154ac8SAndrew Moore(list) , 43030154ac8SAndrew Mooreor 43100c2adfeSPhilippe Charnier.Em n 43230154ac8SAndrew Moore(enumerate), 43330154ac8SAndrew Mooreto print the last line affected by the command. 43430154ac8SAndrew Moore 43530154ac8SAndrew MooreAn interrupt (typically ^C) has the effect of aborting the current command 43630154ac8SAndrew Mooreand returning the editor to command mode. 43730154ac8SAndrew Moore 43800c2adfeSPhilippe Charnier.Nm Ed 43930154ac8SAndrew Moorerecognizes the following commands. The commands are shown together with 44030154ac8SAndrew Moorethe default address or address range supplied if none is 44130154ac8SAndrew Moorespecified (in parenthesis). 44200c2adfeSPhilippe Charnier.Bl -tag -width indent 44300c2adfeSPhilippe Charnier.It (.)a 44400c2adfeSPhilippe CharnierAppend text to the buffer after the addressed line. 44530154ac8SAndrew MooreText is entered in input mode. 44630154ac8SAndrew MooreThe current address is set to last line entered. 44700c2adfeSPhilippe Charnier.It (.,.)c 44800c2adfeSPhilippe CharnierChange lines in the buffer. The addressed lines are deleted 44930154ac8SAndrew Moorefrom the buffer, and text is appended in their place. 45030154ac8SAndrew MooreText is entered in input mode. 45130154ac8SAndrew MooreThe current address is set to last line entered. 45200c2adfeSPhilippe Charnier.It (.,.)d 45300c2adfeSPhilippe CharnierDelete the addressed lines from the buffer. 45430154ac8SAndrew MooreIf there is a line after the deleted range, then the current address is set 45530154ac8SAndrew Mooreto this line. Otherwise the current address is set to the line 45630154ac8SAndrew Moorebefore the deleted range. 45700c2adfeSPhilippe Charnier.It e Ar file 45800c2adfeSPhilippe CharnierEdit 45900c2adfeSPhilippe Charnier.Ar file , 46030154ac8SAndrew Mooreand sets the default filename. 46130154ac8SAndrew MooreIf 46200c2adfeSPhilippe Charnier.Ar file 46330154ac8SAndrew Mooreis not specified, then the default filename is used. 46430154ac8SAndrew MooreAny lines in the buffer are deleted before 46530154ac8SAndrew Moorethe new file is read. 46630154ac8SAndrew MooreThe current address is set to the last line read. 46700c2adfeSPhilippe Charnier.It e Ar !command 46800c2adfeSPhilippe CharnierEdit the standard output of 46900c2adfeSPhilippe Charnier.Ar !command , 47095e6217eSAndrew Moore(see 47100c2adfeSPhilippe Charnier.Ar !command 47295e6217eSAndrew Moorebelow). 47330154ac8SAndrew MooreThe default filename is unchanged. 47430154ac8SAndrew MooreAny lines in the buffer are deleted before the output of 47500c2adfeSPhilippe Charnier.Ar command 47630154ac8SAndrew Mooreis read. 47730154ac8SAndrew MooreThe current address is set to the last line read. 47800c2adfeSPhilippe Charnier.It E Ar file 47900c2adfeSPhilippe CharnierEdit 48000c2adfeSPhilippe Charnier.Ar file 48130154ac8SAndrew Mooreunconditionally. 48230154ac8SAndrew MooreThis is similar to the 48300c2adfeSPhilippe Charnier.Em e 48430154ac8SAndrew Moorecommand, 48530154ac8SAndrew Mooreexcept that unwritten changes are discarded without warning. 48630154ac8SAndrew MooreThe current address is set to the last line read. 48700c2adfeSPhilippe Charnier.It f Ar file 48800c2adfeSPhilippe CharnierSet the default filename to 48900c2adfeSPhilippe Charnier.Ar file . 49030154ac8SAndrew MooreIf 49100c2adfeSPhilippe Charnier.Ar file 49230154ac8SAndrew Mooreis not specified, then the default unescaped filename is printed. 49300c2adfeSPhilippe Charnier.It (1,$)g/re/command-list 49400c2adfeSPhilippe CharnierApply 49500c2adfeSPhilippe Charnier.Ar command-list 49630154ac8SAndrew Mooreto each of the addressed lines matching a regular expression 49700c2adfeSPhilippe Charnier.Ar re . 49830154ac8SAndrew MooreThe current address is set to the 49930154ac8SAndrew Mooreline currently matched before 50000c2adfeSPhilippe Charnier.Ar command-list 50130154ac8SAndrew Mooreis executed. 50230154ac8SAndrew MooreAt the end of the 50300c2adfeSPhilippe Charnier.Em g 50430154ac8SAndrew Moorecommand, the current address is set to the last line affected by 50500c2adfeSPhilippe Charnier.Ar command-list . 50600c2adfeSPhilippe Charnier.Pp 50730154ac8SAndrew MooreEach command in 50800c2adfeSPhilippe Charnier.Ar command-list 50930154ac8SAndrew Mooremust be on a separate line, 51030154ac8SAndrew Mooreand every line except for the last must be terminated by a backslash 51130154ac8SAndrew Moore(\\). 51230154ac8SAndrew MooreAny commands are allowed, except for 51300c2adfeSPhilippe Charnier.Em g , 51400c2adfeSPhilippe Charnier.Em G , 51500c2adfeSPhilippe Charnier.Em v , 51630154ac8SAndrew Mooreand 51700c2adfeSPhilippe Charnier.Em V . 51830154ac8SAndrew MooreA newline alone in 51900c2adfeSPhilippe Charnier.Ar command-list 52030154ac8SAndrew Mooreis equivalent to a 52100c2adfeSPhilippe Charnier.Em p 52230154ac8SAndrew Moorecommand. 52300c2adfeSPhilippe Charnier.It (1,$)G/re/ 52400c2adfeSPhilippe CharnierInteractively edit the addressed lines matching a regular expression 52500c2adfeSPhilippe Charnier.Ar re . 52630154ac8SAndrew MooreFor each matching line, 52730154ac8SAndrew Moorethe line is printed, 52830154ac8SAndrew Moorethe current address is set, 52930154ac8SAndrew Mooreand the user is prompted to enter a 53000c2adfeSPhilippe Charnier.Ar command-list . 53130154ac8SAndrew MooreAt the end of the 53200c2adfeSPhilippe Charnier.Em G 53330154ac8SAndrew Moorecommand, the current address 53430154ac8SAndrew Mooreis set to the last line affected by (the last) 53500c2adfeSPhilippe Charnier.Ar command-list . 53600c2adfeSPhilippe Charnier.Pp 53730154ac8SAndrew MooreThe format of 53800c2adfeSPhilippe Charnier.Ar command-list 53930154ac8SAndrew Mooreis the same as that of the 54000c2adfeSPhilippe Charnier.Em g 54130154ac8SAndrew Moorecommand. A newline alone acts as a null command list. 54230154ac8SAndrew MooreA single `&' repeats the last non-null command list. 54300c2adfeSPhilippe Charnier.It H 54400c2adfeSPhilippe CharnierToggle the printing of error explanations. 54530154ac8SAndrew MooreBy default, explanations are not printed. 54630154ac8SAndrew MooreIt is recommended that ed scripts begin with this command to 54730154ac8SAndrew Mooreaid in debugging. 54800c2adfeSPhilippe Charnier.It h 54900c2adfeSPhilippe CharnierPrint an explanation of the last error. 55000c2adfeSPhilippe Charnier.It (.)i 55100c2adfeSPhilippe CharnierInsert text in the buffer before the current line. 55230154ac8SAndrew MooreText is entered in input mode. 55330154ac8SAndrew MooreThe current address is set to the last line entered. 55400c2adfeSPhilippe Charnier.It (.,.+1)j 55500c2adfeSPhilippe CharnierJoin the addressed lines. The addressed lines are 55630154ac8SAndrew Mooredeleted from the buffer and replaced by a single 55730154ac8SAndrew Mooreline containing their joined text. 55830154ac8SAndrew MooreThe current address is set to the resultant line. 55900c2adfeSPhilippe Charnier.It (.)klc 56000c2adfeSPhilippe CharnierMark a line with a lower case letter 56100c2adfeSPhilippe Charnier.Em lc . 56230154ac8SAndrew MooreThe line can then be addressed as 56300c2adfeSPhilippe Charnier.Em 'lc 56430154ac8SAndrew Moore(i.e., a single quote followed by 56500c2adfeSPhilippe Charnier.Em lc 56630154ac8SAndrew Moore) in subsequent commands. The mark is not cleared until the line is 56730154ac8SAndrew Mooredeleted or otherwise modified. 56800c2adfeSPhilippe Charnier.It (.,.)l 56900c2adfeSPhilippe CharnierPrint the addressed lines unambiguously. 57095e6217eSAndrew MooreIf a single line fills for than one screen (as might be the case 57195e6217eSAndrew Moorewhen viewing a binary file, for instance), a `--More--' 57295e6217eSAndrew Mooreprompt is printed on the last line. 57300c2adfeSPhilippe Charnier.Nm Ed 57495e6217eSAndrew Moorewaits until the RETURN key is pressed 57595e6217eSAndrew Moorebefore displaying the next screen. 57630154ac8SAndrew MooreThe current address is set to the last line 57730154ac8SAndrew Mooreprinted. 57800c2adfeSPhilippe Charnier.It (.,.)m(.) 57900c2adfeSPhilippe CharnierMove lines in the buffer. The addressed lines are moved to after the 58030154ac8SAndrew Mooreright-hand destination address, which may be the address 58100c2adfeSPhilippe Charnier.Em 0 58230154ac8SAndrew Moore(zero). 58330154ac8SAndrew MooreThe current address is set to the 58430154ac8SAndrew Moorelast line moved. 58500c2adfeSPhilippe Charnier.It (.,.)n 58600c2adfeSPhilippe CharnierPrint the addressed lines along with 58730154ac8SAndrew Mooretheir line numbers. The current address is set to the last line 58830154ac8SAndrew Mooreprinted. 58900c2adfeSPhilippe Charnier.It (.,.)p 59000c2adfeSPhilippe CharnierPrint the addressed lines. The current address is set to the last line 59130154ac8SAndrew Mooreprinted. 59200c2adfeSPhilippe Charnier.It P 59300c2adfeSPhilippe CharnierToggle the command prompt on and off. 59430154ac8SAndrew MooreUnless a prompt was specified by with command-line option 59500c2adfeSPhilippe Charnier.Fl p Ar string , 59600c2adfeSPhilippe Charnierthe command prompt is by default turned off. 59700c2adfeSPhilippe Charnier.It q 59800c2adfeSPhilippe CharnierQuit 59900c2adfeSPhilippe Charnier.Nm Ns . 60000c2adfeSPhilippe Charnier.It Q 60100c2adfeSPhilippe CharnierQuit 60200c2adfeSPhilippe Charnier.Nm 60300c2adfeSPhilippe Charnierunconditionally. 60430154ac8SAndrew MooreThis is similar to the 60500c2adfeSPhilippe Charnier.Em q 60630154ac8SAndrew Moorecommand, 60730154ac8SAndrew Mooreexcept that unwritten changes are discarded without warning. 60800c2adfeSPhilippe Charnier.It ($)r Ar file 60900c2adfeSPhilippe CharnierRead 61000c2adfeSPhilippe Charnier.Ar file 61130154ac8SAndrew Mooreto after the addressed line. If 61200c2adfeSPhilippe Charnier.Ar file 61330154ac8SAndrew Mooreis not specified, then the default 61430154ac8SAndrew Moorefilename is used. If there was no default filename prior to the command, 61530154ac8SAndrew Moorethen the default filename is set to 61600c2adfeSPhilippe Charnier.Ar file . 61730154ac8SAndrew MooreOtherwise, the default filename is unchanged. 61830154ac8SAndrew MooreThe current address is set to the last line read. 61900c2adfeSPhilippe Charnier.It ($)r Ar !command 62000c2adfeSPhilippe CharnierRead 62130154ac8SAndrew Mooreto after the addressed line 62230154ac8SAndrew Moorethe standard output of 62300c2adfeSPhilippe Charnier.Ar !command , 62495e6217eSAndrew Moore(see the 62500c2adfeSPhilippe Charnier.Ar !command 62695e6217eSAndrew Moorebelow). 62730154ac8SAndrew MooreThe default filename is unchanged. 62830154ac8SAndrew MooreThe current address is set to the last line read. 62900c2adfeSPhilippe Charnier.It (.,.)s/re/replacement/ 63000c2adfeSPhilippe Charnier.It (.,.)s/re/replacement/g 63100c2adfeSPhilippe Charnier.It (.,.)s/re/replacement/n 63200c2adfeSPhilippe CharnierReplace text in the addressed lines 63330154ac8SAndrew Moorematching a regular expression 63400c2adfeSPhilippe Charnier.Ar re 63530154ac8SAndrew Moorewith 63600c2adfeSPhilippe Charnier.Ar replacement . 63730154ac8SAndrew MooreBy default, only the first match in each line is replaced. 63895e6217eSAndrew MooreIf the 63900c2adfeSPhilippe Charnier.Em g 64095e6217eSAndrew Moore(global) suffix is given, then every match to be replaced. 64130154ac8SAndrew MooreThe 64200c2adfeSPhilippe Charnier.Em n 64330154ac8SAndrew Mooresuffix, where 64400c2adfeSPhilippe Charnier.Em n 64560fd953fSJordan K. Hubbardis a positive number, causes only the 64600c2adfeSPhilippe Charnier.Em n Ns th 64730154ac8SAndrew Moorematch to be replaced. 64830154ac8SAndrew MooreIt is an error if no substitutions are performed on any of the addressed 64930154ac8SAndrew Moorelines. 65030154ac8SAndrew MooreThe current address is set the last line affected. 65100c2adfeSPhilippe Charnier.Pp 65200c2adfeSPhilippe Charnier.Ar Re 65330154ac8SAndrew Mooreand 65400c2adfeSPhilippe Charnier.Ar replacement 65595e6217eSAndrew Mooremay be delimited by any character other than space and newline 65695e6217eSAndrew Moore(see the 65700c2adfeSPhilippe Charnier.Em s 65895e6217eSAndrew Moorecommand below). 65930154ac8SAndrew MooreIf one or two of the last delimiters is omitted, then the last line 66030154ac8SAndrew Mooreaffected is printed as though the print suffix 66100c2adfeSPhilippe Charnier.Em p 66230154ac8SAndrew Moorewere specified. 66300c2adfeSPhilippe Charnier.Pp 66430154ac8SAndrew MooreAn unescaped `&' in 66500c2adfeSPhilippe Charnier.Ar replacement 66630154ac8SAndrew Mooreis replaced by the currently matched text. 66730154ac8SAndrew MooreThe character sequence 66800c2adfeSPhilippe Charnier.Em \em , 66930154ac8SAndrew Moorewhere 67000c2adfeSPhilippe Charnier.Em m 67130154ac8SAndrew Mooreis a number in the range [1,9], is replaced by the 67200c2adfeSPhilippe Charnier.Em m th 67330154ac8SAndrew Moorebackreference expression of the matched text. 67430154ac8SAndrew MooreIf 67500c2adfeSPhilippe Charnier.Ar replacement 67630154ac8SAndrew Mooreconsists of a single `%', then 67700c2adfeSPhilippe Charnier.Ar replacement 67830154ac8SAndrew Moorefrom the last substitution is used. 67930154ac8SAndrew MooreNewlines may be embedded in 68000c2adfeSPhilippe Charnier.Ar replacement 68130154ac8SAndrew Mooreif they are escaped with a backslash (\\). 68200c2adfeSPhilippe Charnier.It (.,.)s 68300c2adfeSPhilippe CharnierRepeat the last substitution. 68430154ac8SAndrew MooreThis form of the 68500c2adfeSPhilippe Charnier.Em s 68695e6217eSAndrew Moorecommand accepts a count suffix 68700c2adfeSPhilippe Charnier.Em n , 68895e6217eSAndrew Mooreor any combination of the characters 68900c2adfeSPhilippe Charnier.Em r , 69000c2adfeSPhilippe Charnier.Em g , 69130154ac8SAndrew Mooreand 69200c2adfeSPhilippe Charnier.Em p . 69395e6217eSAndrew MooreIf a count suffix 69400c2adfeSPhilippe Charnier.Em n 69595e6217eSAndrew Mooreis given, then only the 69600c2adfeSPhilippe Charnier.Em n Ns th 69795e6217eSAndrew Moorematch is replaced. 69830154ac8SAndrew MooreThe 69900c2adfeSPhilippe Charnier.Em r 70030154ac8SAndrew Mooresuffix causes 70130154ac8SAndrew Moorethe regular expression of the last search to be used instead of the 70230154ac8SAndrew Moorethat of the last substitution. 70330154ac8SAndrew MooreThe 70400c2adfeSPhilippe Charnier.Em g 70530154ac8SAndrew Mooresuffix toggles the global suffix of the last substitution. 70630154ac8SAndrew MooreThe 70700c2adfeSPhilippe Charnier.Em p 70830154ac8SAndrew Mooresuffix toggles the print suffix of the last substitution 70930154ac8SAndrew MooreThe current address is set to the last line affected. 71000c2adfeSPhilippe Charnier.It (.,.)t(.) 71100c2adfeSPhilippe CharnierCopy (i.e., transfer) the addressed lines to after the right-hand 71230154ac8SAndrew Mooredestination address, which may be the address 71300c2adfeSPhilippe Charnier.Em 0 71430154ac8SAndrew Moore(zero). 71530154ac8SAndrew MooreThe current address is set to the last line 71630154ac8SAndrew Moorecopied. 71700c2adfeSPhilippe Charnier.It u 71800c2adfeSPhilippe CharnierUndo the last command and restores the current address 71930154ac8SAndrew Mooreto what it was before the command. 72030154ac8SAndrew MooreThe global commands 72100c2adfeSPhilippe Charnier.Em g , 72200c2adfeSPhilippe Charnier.Em G , 72300c2adfeSPhilippe Charnier.Em v , 72430154ac8SAndrew Mooreand 72500c2adfeSPhilippe Charnier.Em V . 72630154ac8SAndrew Mooreare treated as a single command by undo. 72700c2adfeSPhilippe Charnier.Em u 72830154ac8SAndrew Mooreis its own inverse. 72900c2adfeSPhilippe Charnier.It (1,$)v/re/command-list 73000c2adfeSPhilippe CharnierApply 73100c2adfeSPhilippe Charnier.Ar command-list 73230154ac8SAndrew Mooreto each of the addressed lines not matching a regular expression 73300c2adfeSPhilippe Charnier.Ar re . 73430154ac8SAndrew MooreThis is similar to the 73500c2adfeSPhilippe Charnier.Em g 73630154ac8SAndrew Moorecommand. 73700c2adfeSPhilippe Charnier.It (1,$)V/re/ 73800c2adfeSPhilippe CharnierInteractively edit the addressed lines not matching a regular expression 73900c2adfeSPhilippe Charnier.Ar re . 74030154ac8SAndrew MooreThis is similar to the 74100c2adfeSPhilippe Charnier.Em G 74230154ac8SAndrew Moorecommand. 74300c2adfeSPhilippe Charnier.It (1,$)w Ar file 74400c2adfeSPhilippe CharnierWrite the addressed lines to 74500c2adfeSPhilippe Charnier.Ar file . 74630154ac8SAndrew MooreAny previous contents of 74700c2adfeSPhilippe Charnier.Ar file 74830154ac8SAndrew Mooreis lost without warning. 74930154ac8SAndrew MooreIf there is no default filename, then the default filename is set to 75000c2adfeSPhilippe Charnier.Ar file , 75130154ac8SAndrew Mooreotherwise it is unchanged. If no filename is specified, then the default 75230154ac8SAndrew Moorefilename is used. 75330154ac8SAndrew MooreThe current address is unchanged. 75400c2adfeSPhilippe Charnier.It (1,$)wq Ar file 75500c2adfeSPhilippe CharnierWrite the addressed lines to 75600c2adfeSPhilippe Charnier.Ar file , 75730154ac8SAndrew Mooreand then executes a 75800c2adfeSPhilippe Charnier.Em q 75930154ac8SAndrew Moorecommand. 76000c2adfeSPhilippe Charnier.It (1,$)w Ar !command 76100c2adfeSPhilippe CharnierWrite the addressed lines to the standard input of 76200c2adfeSPhilippe Charnier.Ar !command , 76395e6217eSAndrew Moore(see the 76400c2adfeSPhilippe Charnier.Em !command 76595e6217eSAndrew Moorebelow). 76630154ac8SAndrew MooreThe default filename and current address are unchanged. 76700c2adfeSPhilippe Charnier.It (1,$)W Ar file 76800c2adfeSPhilippe CharnierAppend the addressed lines to the end of 76900c2adfeSPhilippe Charnier.Ar file . 77030154ac8SAndrew MooreThis is similar to the 77100c2adfeSPhilippe Charnier.Em w 77230154ac8SAndrew Moorecommand, expect that the previous contents of file is not clobbered. 77330154ac8SAndrew MooreThe current address is unchanged. 77400c2adfeSPhilippe Charnier.It x 77500c2adfeSPhilippe CharnierPrompt for an encryption key which is used in subsequent reads and 77630154ac8SAndrew Moorewrites. If a newline alone is entered as the key, then encryption is 77730154ac8SAndrew Mooreturned off. Otherwise, echoing is disabled while a key is read. 77800c2adfeSPhilippe CharnierEncryption/decryption is done using the 77900c2adfeSPhilippe Charnier.Xr bdes 1 78000c2adfeSPhilippe Charnieralgorithm. 78100c2adfeSPhilippe Charnier.It Pf (.+1)z n 78200c2adfeSPhilippe CharnierScroll 78300c2adfeSPhilippe Charnier.Ar n 78430154ac8SAndrew Moorelines at a time starting at addressed line. If 78500c2adfeSPhilippe Charnier.Ar n 78630154ac8SAndrew Mooreis not specified, then the current window size is used. 78730154ac8SAndrew MooreThe current address is set to the last line printed. 78800c2adfeSPhilippe Charnier.It !command 78900c2adfeSPhilippe CharnierExecute 79000c2adfeSPhilippe Charnier.Ar command 79130154ac8SAndrew Moorevia 79200c2adfeSPhilippe Charnier.Xr sh 1 . 79330154ac8SAndrew MooreIf the first character of 79400c2adfeSPhilippe Charnier.Ar command 79530154ac8SAndrew Mooreis `!', then it is replaced by text of the 79630154ac8SAndrew Mooreprevious 79700c2adfeSPhilippe Charnier.Ar !command . 79800c2adfeSPhilippe Charnier.Nm Ed 79930154ac8SAndrew Mooredoes not process 80000c2adfeSPhilippe Charnier.Ar command 80130154ac8SAndrew Moorefor backslash (\\) escapes. 80230154ac8SAndrew MooreHowever, an unescaped 80300c2adfeSPhilippe Charnier.Em % 80430154ac8SAndrew Mooreis replaced by the default filename. 80530154ac8SAndrew MooreWhen the shell returns from execution, a `!' 80630154ac8SAndrew Mooreis printed to the standard output. 80730154ac8SAndrew MooreThe current line is unchanged. 80800c2adfeSPhilippe Charnier.It ($)= 80900c2adfeSPhilippe CharnierPrint the line number of the addressed line. 81000c2adfeSPhilippe Charnier.It (.+1)newline 81100c2adfeSPhilippe CharnierPrint the addressed line, and sets the current address to 81230154ac8SAndrew Moorethat line. 81300c2adfeSPhilippe Charnier.El 81400c2adfeSPhilippe Charnier.Sh FILES 81500c2adfeSPhilippe Charnier.Bl -tag -width /tmp/ed.* -compact 81600c2adfeSPhilippe Charnier.It /tmp/ed.* 81700c2adfeSPhilippe Charnierbuffer file 81800c2adfeSPhilippe Charnier.It ed.hup 81900c2adfeSPhilippe Charnierthe file to which 82000c2adfeSPhilippe Charnier.Nm 82100c2adfeSPhilippe Charnierattempts to write the buffer if the terminal hangs up 82200c2adfeSPhilippe Charnier.El 82300c2adfeSPhilippe Charnier.Sh SEE ALSO 82400c2adfeSPhilippe Charnier.Xr bdes 1 , 82500c2adfeSPhilippe Charnier.Xr sed 1 , 82600c2adfeSPhilippe Charnier.Xr sh 1 , 82700c2adfeSPhilippe Charnier.Xr vi 1 , 82800c2adfeSPhilippe Charnier.Xr regex 3 82930154ac8SAndrew Moore 83030154ac8SAndrew MooreUSD:12-13 83130154ac8SAndrew Moore 83200c2adfeSPhilippe Charnier.Rs 83300c2adfeSPhilippe Charnier.%A B. W. Kernighan and P. J. Plauger 83400c2adfeSPhilippe Charnier.%B Software Tools in Pascal 83500c2adfeSPhilippe Charnier.%O Addison-Wesley 83600c2adfeSPhilippe Charnier.%D 1981 83700c2adfeSPhilippe Charnier.Re 83830154ac8SAndrew Moore 83900c2adfeSPhilippe Charnier.Sh LIMITATIONS 84000c2adfeSPhilippe Charnier.Nm Ed 84130154ac8SAndrew Mooreprocesses 84200c2adfeSPhilippe Charnier.Ar file 84330154ac8SAndrew Moorearguments for backslash escapes, i.e., in a filename, 84430154ac8SAndrew Mooreany characters preceded by a backslash (\\) are 84530154ac8SAndrew Mooreinterpreted literally. 84630154ac8SAndrew Moore 84730154ac8SAndrew MooreIf a text (non-binary) file is not terminated by a newline character, 84830154ac8SAndrew Moorethen 84900c2adfeSPhilippe Charnier.Nm 85030154ac8SAndrew Mooreappends one on reading/writing it. In the case of a binary file, 85100c2adfeSPhilippe Charnier.Nm 85230154ac8SAndrew Mooredoes not append a newline on reading/writing. 85330154ac8SAndrew Moore 85430154ac8SAndrew Mooreper line overhead: 4 ints 85530154ac8SAndrew Moore 85600c2adfeSPhilippe Charnier.Sh DIAGNOSTICS 85730154ac8SAndrew MooreWhen an error occurs, 85800c2adfeSPhilippe Charnier.Nm 85930154ac8SAndrew Mooreprints a `?' and either returns to command mode 86030154ac8SAndrew Mooreor exits if its input is from a script. 86130154ac8SAndrew MooreAn explanation of the last error can be 86230154ac8SAndrew Mooreprinted with the 86300c2adfeSPhilippe Charnier.Em h 86430154ac8SAndrew Moore(help) command. 86530154ac8SAndrew Moore 86630154ac8SAndrew MooreSince the 86700c2adfeSPhilippe Charnier.Em g 86830154ac8SAndrew Moore(global) command masks any errors from failed searches and substitutions, 86930154ac8SAndrew Mooreit can be used to perform conditional operations in scripts; e.g., 87000c2adfeSPhilippe Charnier.Pp 87100c2adfeSPhilippe Charnier.Sm off 87200c2adfeSPhilippe Charnier.Cm g No / Em old Xo 87300c2adfeSPhilippe Charnier.No / Cm s 87400c2adfeSPhilippe Charnier.No // Em new 87500c2adfeSPhilippe Charnier.No / 87600c2adfeSPhilippe Charnier.Xc 87700c2adfeSPhilippe Charnier.Sm on 87800c2adfeSPhilippe Charnier.Pp 87930154ac8SAndrew Moorereplaces any occurrences of 88000c2adfeSPhilippe Charnier.Em old 88130154ac8SAndrew Moorewith 88200c2adfeSPhilippe Charnier.Em new . 88310ca1c6cSAndrew MooreIf the 88400c2adfeSPhilippe Charnier.Em u 88510ca1c6cSAndrew Moore(undo) command occurs in a global command list, then 88610ca1c6cSAndrew Moorethe command list is executed only once. 88730154ac8SAndrew Moore 88830154ac8SAndrew MooreIf diagnostics are not disabled, attempting to quit 88900c2adfeSPhilippe Charnier.Nm 89030154ac8SAndrew Mooreor edit another file before writing a modified buffer 89130154ac8SAndrew Mooreresults in an error. 89230154ac8SAndrew MooreIf the command is entered a second time, it succeeds, 89330154ac8SAndrew Moorebut any changes to the buffer are lost. 89400c2adfeSPhilippe Charnier.Sh HISTORY 895b8923d4cSWolfram SchneiderA 89600c2adfeSPhilippe Charnier.Nm 897b8923d4cSWolfram Schneidercommand appeared in 898b8923d4cSWolfram SchneiderVersion 1 AT&T UNIX. 899