Imagine you have a text file (txt.txt in the example) containing the following few lines:
1234
1123
2345
a1a2
abba
abab
%66%
%%df
\\

and you want to extract the lines containing duplicate characters. The result will be the following:
1123
a1a2
abba
abab
%66%
%%df
\\

Naturally we’ll use the bash

shell1

 

To reach the above result you can use grep as follows:
$ grep '\(.\).*\1' txt.txt

and the result is:
# grep '\(.\).*\1' txt.txt
1123
a1a2
abba
abab
%66%
%%df
\\

If you want to filter out non consecutive duplicate characters, you have 2 choiches using perl or awk:
$ perl -ne 'print if/(.)\1/' txt.txt
1123
abba
%66%
%%df
\\

$ awk -F "" '{for(i=1; i<NF;i++) if($i==$(i+1)) {print; next}}' txt.txt
1123
abba
%66%
%%df
\\

gg1