删除文本的最有效方法是什么2010-04-07 14:25:50,773 DEBUG这是一个调试日志语句 -来自日志文件,如下面使用Vim的摘录?
2010-04-07 14:25:50,772 DEBUG This is a debug log statement - 9,8 2010-04-07 14:25:50,772 DEBUG This is a debug log statement - 1,11 2010-04-07 14:25:50,772 DEBUG This is a debug log statement - 5,2 2010-04-07 14:25:50,772 DEBUG This is a debug log statement - 8,4
这就是结果应该是这样的:
9,8 1,11 5,2 8,4
请注意,在这种情况下我在Windows上使用gVim,所以请不要建议任何可能更适合该任务的UNIX程序 - 我必须使用Vim来完成它.
Ste*_*hen 13
运行命令: :%s/.* - //
编辑,解释:
%: whole file
s: subsitute
.* - : find any text followed by a space a dash and a space.
// : replace it with the empty string.
Run Code Online (Sandbox Code Playgroud)
您还可以使用可视块模式选择要删除的所有字符:
gg Go to the beginning of the file
Ctrl-v Enter visual block mode
G Go to the end of the file
f- Go to dash
<right> Go one more to the right
d Delete the selected block
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1120 次 |
| 最近记录: |