Find lines in file that contain duplicate characters
问题 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 :) A small example just to make things clear: file.txt: 1234 11234 abcd 12234 ab321 1233 zs11w 12w2 the desired output: 11234 12234 1233 zs11w 12w2 Thanks for all your help! 回答1: grep '\(.\).*\1' file.txt Matches any line that contains a character, any string, and then that same character, i.e. any line with duplicates. 回答2: Perl: perl -ne 'print if /(.)