Print the lines that only with all consecutive repeated characters

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a text file and I want to print only the lines that have all their characters are consecutively reapeated at least two times or more.
FOR EXAMPLE THE INPUT:
11
AAA
555227777
BBhh@@222
baabbb
1112
212211
baa
22333445
322113
ÃÂ The output should be:
11
AAA
555227777
BBhh@@222
ÃÂ The output contains only these four lines becauseÃÂ they have only consecutively duplicate characters in order.
I have tried this code
grep '(^| )([ÃÂ ÃÂ ])21($| )' INFILE
But its not working exactly.
text-processing grep
add a comment |Â
up vote
0
down vote
favorite
I have a text file and I want to print only the lines that have all their characters are consecutively reapeated at least two times or more.
FOR EXAMPLE THE INPUT:
11
AAA
555227777
BBhh@@222
baabbb
1112
212211
baa
22333445
322113
ÃÂ The output should be:
11
AAA
555227777
BBhh@@222
ÃÂ The output contains only these four lines becauseÃÂ they have only consecutively duplicate characters in order.
I have tried this code
grep '(^| )([ÃÂ ÃÂ ])21($| )' INFILE
But its not working exactly.
text-processing grep
a revert answer to your previous question is required only here. All your questions are in same category, so you exercise something?
â sddgob
17 mins ago
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a text file and I want to print only the lines that have all their characters are consecutively reapeated at least two times or more.
FOR EXAMPLE THE INPUT:
11
AAA
555227777
BBhh@@222
baabbb
1112
212211
baa
22333445
322113
ÃÂ The output should be:
11
AAA
555227777
BBhh@@222
ÃÂ The output contains only these four lines becauseÃÂ they have only consecutively duplicate characters in order.
I have tried this code
grep '(^| )([ÃÂ ÃÂ ])21($| )' INFILE
But its not working exactly.
text-processing grep
I have a text file and I want to print only the lines that have all their characters are consecutively reapeated at least two times or more.
FOR EXAMPLE THE INPUT:
11
AAA
555227777
BBhh@@222
baabbb
1112
212211
baa
22333445
322113
ÃÂ The output should be:
11
AAA
555227777
BBhh@@222
ÃÂ The output contains only these four lines becauseÃÂ they have only consecutively duplicate characters in order.
I have tried this code
grep '(^| )([ÃÂ ÃÂ ])21($| )' INFILE
But its not working exactly.
text-processing grep
text-processing grep
edited 23 mins ago
Jeff Schaller
34.2k851113
34.2k851113
asked 28 mins ago
Ahmed
404
404
a revert answer to your previous question is required only here. All your questions are in same category, so you exercise something?
â sddgob
17 mins ago
add a comment |Â
a revert answer to your previous question is required only here. All your questions are in same category, so you exercise something?
â sddgob
17 mins ago
a revert answer to your previous question is required only here. All your questions are in same category, so you exercise something?
â sddgob
17 mins ago
a revert answer to your previous question is required only here. All your questions are in same category, so you exercise something?
â sddgob
17 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
You could invert this answer:
sed -n -e '/^(.)11*$/p' < input > output
... or the grep variation:
grep '^(.)11*$' < input > output
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You could invert this answer:
sed -n -e '/^(.)11*$/p' < input > output
... or the grep variation:
grep '^(.)11*$' < input > output
add a comment |Â
up vote
0
down vote
You could invert this answer:
sed -n -e '/^(.)11*$/p' < input > output
... or the grep variation:
grep '^(.)11*$' < input > output
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You could invert this answer:
sed -n -e '/^(.)11*$/p' < input > output
... or the grep variation:
grep '^(.)11*$' < input > output
You could invert this answer:
sed -n -e '/^(.)11*$/p' < input > output
... or the grep variation:
grep '^(.)11*$' < input > output
answered 19 mins ago
Jeff Schaller
34.2k851113
34.2k851113
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476379%2fprint-the-lines-that-only-with-all-consecutive-repeated-characters%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
a revert answer to your previous question is required only here. All your questions are in same category, so you exercise something?
â sddgob
17 mins ago