1、 需求
ide
在測試的過程當中,會遇到刪除指定的文件行的狀況,如刪除配置文件中無用的信息。
測試
好比有如下文件,要刪除最後3行。
3d
![file1.png 31cb96437834aa557f0f8ce18e3f55be.png](http://static.javashuo.com/static/loading.gif)
2、 解決方法blog
1.咱們知道行號get
sed -i '21,23'd Testfile.log
2.咱們知道關鍵字
it
grep -n 'deleted' Testfile.log #先獲取行號
sed -i '21,23'd Testfile.log
![grepsed (2).png e6d7c2d3d887609e7688145b89e98598.png-wh_](http://static.javashuo.com/static/loading.gif)
3.使用vi命令
class
找到要刪除的行,在命令模式下,鍵入 d3d, 便可刪除。
sed
vi dd可逐行刪除,d(y-x)d可刪除段落行配置