Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1691319
  • 博文数量: 410
  • 博客积分: 9563
  • 博客等级: 中将
  • 技术积分: 4517
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-03 19:59
个人简介

文章分类

全部博文(410)

文章存档

2017年(6)

2016年(1)

2015年(3)

2014年(4)

2013年(32)

2012年(45)

2011年(179)

2010年(140)

分类: LINUX

2011-06-29 22:36:59


如果有重复行,保留最后一行,删除前面的相同行
:g/^\(.*\)$\n\1$/d


如果有重复行,保留最前面的行,删除后面的相同行
:g/\%(^\1$\n\)\@<=\(.*\)$/d

g//d <-- Delete the lines matching the regexp
\@<= <-- If the bit following matches, make sure the bit preceding this symbol directly precedes the match
\(.*\)$ <-- Match the line into subst register 1
\%( ) <--- Group without placing in a subst register.
^\1$\n <--- Match subst register 1 followed by end of line and the new line between the 2 lines
阅读(1552) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~