删除vi中的连续重复行,不进行排序 [英] Removing contiguous duplicate lines in vi without sorting

查看:100
本文介绍了删除vi中的连续重复行,不进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题已经解决了如何删除重复的行,但强制执行列表首先排序



我想执行删除连续的重复行步骤(即 uniq ),而无需先对其进行排序。 p>

以前的例子:

  Foo 
Foo
Bar
Bar

示例:

  Foo 
Bar


解决方案

刚刚找到了解决方案 here 。以下正则表达式正确工作:

  g / ^ \(。* \)$ \\\
\1 $ / d


This question already addresses how to remove duplicate lines, but enforces that the list is sorted first.

I would like to perform the remove contiguous duplicate lines step (i.e. uniq) without first sorting them.

Example before:

Foo
Foo
Bar
Bar

Example after:

Foo
Bar

解决方案

Just found the solution here. The following regex works correctly:

g/^\(.*\)$\n\1$/d

这篇关于删除vi中的连续重复行,不进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆