ed

Official Description

The ed command is a line editing program.

Syntax

ed [-p string] [-s] [file]

Options

-p string sets the ed prompt to string.

-s suppresses diagnostics (which is useful for scripts).

Oddities

The default for string is null (no prompt).

Example

$ cat buzz
#! /bin/ksh
integer x=17
while :
do
x=17
done
$
$ ed buzz                    # Use ed to edit the buzz file
47                           # Character count is automatically displayed
2                            # Command 2 means display line 2
integer x=17
s/17/23/                     # Changes the 17 to a 23
2                            # Redisplay line 2
integer x=23
3                            # Display line 3
while :
q
?                            # Editor displays a ? when confused
q                            # Quit the editor, (w saves changes)
$
$ cat -n buzz
     1  #! /bin/ksh
     2  integer x=17
     3  while :
     4  do
     5  x=17
     6  done
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.