Shell命令详解:功能、用法与示例
1. ed命令
1.1 功能及选项
ed命令用于文本编辑,其选项如下:
--p string:将ed的提示符设置为指定的字符串,默认字符串为空,即无提示符。
--s:抑制诊断信息,在脚本中使用很有用。
1.2 示例
$ 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 # Qui