[ SDF Public Access UNIX System .. Est. 1987 ]

join welcome faq status members projects store tour gopher abuse dialup dsl minecraft social
tilde nihongo europa webmail gallery usermap teach irc tutorials software telnet ssh

ed Cheat Sheet

ed is a small, powerful, line-oriented, command-line-interfaced text editor. All editors frustrate, but ed often amazes while others disappoint.

ed, man! !man ed — ed is the standard text editor.

man ed for more information.

Start ed from your shell command line:

ed file

Edit file by entering ed commands with the following syntax:

[range][command]

range specifies the line or block of consecutive lines (syntax: from-line,to-line) to which command is applied. Default range is the current line except where noted below with a parenthesis preceding the command syntax. Lines are specified as follows:

nline n .current $last 'cmark c
-[n]up n (default: 1) +[n]down n (default: 1) ,1,$ ;.,$
?re?previous regexp match /re/next regexp match

Input commands

aAppend after. cChange range. iInsert before. .End input mode.

Edit commands

dDelete. s/re/s/[g|n][p]Substitute.
m[line]Move after line. t[line]Copy after line.
(.,+)jJoin lines. uUndo.
(1,$)g/re/cmdsPerform cmds for all matching lines. (1,$)v/re/cmdsPerform cmds for all non-matching lines.

File commands

e [file*]Edit file. E [file*]Edit, discarding changes.
($)r [file]Read and append. f [file]Set/display file name.
(1,$)w [file*]Write. (1,$)W [file*]Append to file.
(1,$)wq [file*]Write and quit.
* In place of file, specify "!shell-command" to read/write text to shell-command standard output/input.

Display commands

pList lines. l… with unprintables. n… with numbers.
(+)z[lines]Scroll. (+)nullp

Other commands

kcMark line. ($)=Display line number. hLast error text.
!shell-commandExecute shell-command. qQuit. QQuit, discarding changes.

$Id: ed.html,v 1.5 2007/10/09 00:27:11 papa Exp $

©1987-2065 SDF Public Access UNIX System, Inc. 501(c)(7)
(this page was generated using ksh, sed and awk)