How to print specified lines only?

Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I want to specify the output from text file in one command as below:
1-Print all lines that have all consecutive duplicates characters.
2-Print all lines with all consecutively repeated characters except the last one or the last two characters in the same line.
3-Print all lines with all consecutively repeated characters except the first one or the first two characters in the same line.
Example: 11122323 1112266 44778 223334456 6778811 845511 3357788
The output should be
1112266 >>>>> All repeated characters.
44778 >>>>> All repeated except the last character.
223334456 >>> All repeated except the last two characters
6778811 >>>> All repeated except the first character.
845511 >>>> All repeated except the first two characters.
Non consecutively repeating characters are allowed, but only if 1st or 2nd from start or end of a line. First line excluded becuse it has #3 is not consecutively repeated.
I have tried this command but it works even with not con
secutive duplicates characters.
awk '
split ("", N) # delete N array
P = 1 # reset boolean L used for print decision
L = length
for (i=1; i<=L; i++) N[substr($0, i, 1)]+=((i<3)
P # print if non-duplicate chars exist only at margins
' file
command-line
add a comment |Â
up vote
-1
down vote
favorite
I want to specify the output from text file in one command as below:
1-Print all lines that have all consecutive duplicates characters.
2-Print all lines with all consecutively repeated characters except the last one or the last two characters in the same line.
3-Print all lines with all consecutively repeated characters except the first one or the first two characters in the same line.
Example: 11122323 1112266 44778 223334456 6778811 845511 3357788
The output should be
1112266 >>>>> All repeated characters.
44778 >>>>> All repeated except the last character.
223334456 >>> All repeated except the last two characters
6778811 >>>> All repeated except the first character.
845511 >>>> All repeated except the first two characters.
Non consecutively repeating characters are allowed, but only if 1st or 2nd from start or end of a line. First line excluded becuse it has #3 is not consecutively repeated.
I have tried this command but it works even with not con
secutive duplicates characters.
awk '
split ("", N) # delete N array
P = 1 # reset boolean L used for print decision
L = length
for (i=1; i<=L; i++) N[substr($0, i, 1)]+=((i<3)
P # print if non-duplicate chars exist only at margins
' file
command-line
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I want to specify the output from text file in one command as below:
1-Print all lines that have all consecutive duplicates characters.
2-Print all lines with all consecutively repeated characters except the last one or the last two characters in the same line.
3-Print all lines with all consecutively repeated characters except the first one or the first two characters in the same line.
Example: 11122323 1112266 44778 223334456 6778811 845511 3357788
The output should be
1112266 >>>>> All repeated characters.
44778 >>>>> All repeated except the last character.
223334456 >>> All repeated except the last two characters
6778811 >>>> All repeated except the first character.
845511 >>>> All repeated except the first two characters.
Non consecutively repeating characters are allowed, but only if 1st or 2nd from start or end of a line. First line excluded becuse it has #3 is not consecutively repeated.
I have tried this command but it works even with not con
secutive duplicates characters.
awk '
split ("", N) # delete N array
P = 1 # reset boolean L used for print decision
L = length
for (i=1; i<=L; i++) N[substr($0, i, 1)]+=((i<3)
P # print if non-duplicate chars exist only at margins
' file
command-line
I want to specify the output from text file in one command as below:
1-Print all lines that have all consecutive duplicates characters.
2-Print all lines with all consecutively repeated characters except the last one or the last two characters in the same line.
3-Print all lines with all consecutively repeated characters except the first one or the first two characters in the same line.
Example: 11122323 1112266 44778 223334456 6778811 845511 3357788
The output should be
1112266 >>>>> All repeated characters.
44778 >>>>> All repeated except the last character.
223334456 >>> All repeated except the last two characters
6778811 >>>> All repeated except the first character.
845511 >>>> All repeated except the first two characters.
Non consecutively repeating characters are allowed, but only if 1st or 2nd from start or end of a line. First line excluded becuse it has #3 is not consecutively repeated.
I have tried this command but it works even with not con
secutive duplicates characters.
awk '
split ("", N) # delete N array
P = 1 # reset boolean L used for print decision
L = length
for (i=1; i<=L; i++) N[substr($0, i, 1)]+=((i<3)
P # print if non-duplicate chars exist only at margins
' file
command-line
command-line
edited 15 mins ago
asked 21 mins ago
Ahmed
565
565
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f477112%2fhow-to-print-specified-lines-only%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