ed
From NetBSD Wiki
ed is the standard editor :)
Usage
Basic Commands
- Open for editing: e filename
- Exit ed: q
- Save file: w [filename]
- Print the whole file to the terminal: ,p
- The same with line numbering: ,n
- Print a screen at a time: z
- Print some lines 20-40: 20,40p
- Use regex: s/^this/to-that/
Sample ed session
A simple one:
$ ed a This is en example text file edited with ed. Using ed looks scarry at the firs glance, but it't very comfortable in fact. . ,p This is en example text file edited with ed. Using ed looks scarry at the firs glance, but it't very comfortable in fact. w ed.txt 123 q
A bit more realistic:
$ ed e script.sh 943 /XXX # XXX this is dirty n 14 # XXX this is dirty .,+5n 14 # XXX this is dirty 15 # 16 MENUTMPFILE="/tmp/stat-`date | digest md5`-$RANDOM" 17 18 # showing selecton dialog 19 # 16p MENUTMPFILE="/tmp/stat-`date | digest md5`-$RANDOM" 16s/`.*`-// 16p MENUTMPFILE="/tmp/stat-$RANDOM" 14,18n 14 # XXX this is dirty 15 # 16 MENUTMPFILE="/tmp/stat-$RANDOM" 17 18 # showing selecton dialog 14c # Creatign tmep file . 14,18n 14 # Creatign tmep file 15 # 16 MENUTMPFILE="/tmp/stat-$RANDOM" 17 18 # showing selecton dialog u 14c # Creating temp file . 14,18n 14 # Creating temp file 15 # 16 MENUTMPFILE="/tmp/stat-$RANDOM" 17 18 # showing selecton dialog w 924 q
