在文件中添加2行

今天又有个需求
需要在某个文本文件中的第一行后面添加两行内容
本想用前面的文章提到的方法
但是用vim
不知道怎样输入控制字符ESC(vim中敲入”ESC”键能从输入状态返回到正常状态)
于是作罢

再试了下古董编辑器ed
感觉不错,呵呵
又复习了下ed的用法
最后的代码是这样的

ed xxx < 1
a
aaaaaa
bbbbbb
.
w
q
END

这样就搞定了
这里”xxx”是我要编辑的文件名
而” aaaaaa
bbbbbb”则是我要在第一行后面添加的2行文本内容

2 Responses to “在文件中添加2行”

  1. 在插入模式下,Ctrl+V+Esc 就可以输入控制符Esc了。

  2. 受教了
    :)

Discussion Area - Leave a Comment




*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word