在文件中查找包含重复字符的行 [英] Find lines in file that contain duplicate characters

查看:162
本文介绍了在文件中查找包含重复字符的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在查找包含重复字符的文本文件中的行时,我需要一些帮助. 我更喜欢使用bash,但是其他任何方法都可以:)

I need some help in locating lines in a text file that contain duplicate characters. I prefer using bash, but any other method will do fine :)

一个简单的例子,以使事情变得清楚:
file.txt:

A small example just to make things clear:
file.txt:

1234
11234
abcd
12234
ab321
1233
zs11w
12w2

所需的输出:

11234
12234
1233
zs11w
12w2

感谢您的所有帮助!

推荐答案

grep '\(.\).*\1' file.txt

匹配包含一个字符,任何字符串然后匹配该相同字符的任何行,即匹配重复的任何行.

Matches any line that contains a character, any string, and then that same character, i.e. any line with duplicates.

这篇关于在文件中查找包含重复字符的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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