Get row data for non-matching column values
I want to read the file (1600 rows) and get rows only the columns have different values (sno1, sno2, sno3 & sno4-should be not be equal value) and it should be above
50%.The example of output given below
input.txt (tab-delimited)
id sno1 sno2 sno3 sno4
R1 98.4 88.8 98.4 67.6
R2 100 100 100 100
R3 33.4 23.5 98.8 45.5
R4 53.5 78.7 88.8 67.5
R5 0 0 0 0
R6 88.8 98.8 67.6 100
ouput.txt
R4 53.5 78.7 88.8 67.5
R6 88.8 98.8 67.6 100
Here in R4 & R6 rows- all column values have not equal to each other and all are above 50%. Any help in awk/sed/perl is appreciated.
sed awk perl
add a comment |
I want to read the file (1600 rows) and get rows only the columns have different values (sno1, sno2, sno3 & sno4-should be not be equal value) and it should be above
50%.The example of output given below
input.txt (tab-delimited)
id sno1 sno2 sno3 sno4
R1 98.4 88.8 98.4 67.6
R2 100 100 100 100
R3 33.4 23.5 98.8 45.5
R4 53.5 78.7 88.8 67.5
R5 0 0 0 0
R6 88.8 98.8 67.6 100
ouput.txt
R4 53.5 78.7 88.8 67.5
R6 88.8 98.8 67.6 100
Here in R4 & R6 rows- all column values have not equal to each other and all are above 50%. Any help in awk/sed/perl is appreciated.
sed awk perl
add a comment |
I want to read the file (1600 rows) and get rows only the columns have different values (sno1, sno2, sno3 & sno4-should be not be equal value) and it should be above
50%.The example of output given below
input.txt (tab-delimited)
id sno1 sno2 sno3 sno4
R1 98.4 88.8 98.4 67.6
R2 100 100 100 100
R3 33.4 23.5 98.8 45.5
R4 53.5 78.7 88.8 67.5
R5 0 0 0 0
R6 88.8 98.8 67.6 100
ouput.txt
R4 53.5 78.7 88.8 67.5
R6 88.8 98.8 67.6 100
Here in R4 & R6 rows- all column values have not equal to each other and all are above 50%. Any help in awk/sed/perl is appreciated.
sed awk perl
I want to read the file (1600 rows) and get rows only the columns have different values (sno1, sno2, sno3 & sno4-should be not be equal value) and it should be above
50%.The example of output given below
input.txt (tab-delimited)
id sno1 sno2 sno3 sno4
R1 98.4 88.8 98.4 67.6
R2 100 100 100 100
R3 33.4 23.5 98.8 45.5
R4 53.5 78.7 88.8 67.5
R5 0 0 0 0
R6 88.8 98.8 67.6 100
ouput.txt
R4 53.5 78.7 88.8 67.5
R6 88.8 98.8 67.6 100
Here in R4 & R6 rows- all column values have not equal to each other and all are above 50%. Any help in awk/sed/perl is appreciated.
sed awk perl
sed awk perl
asked Aug 6 '12 at 21:52
jackjack
1,203102329
1,203102329
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
A perl-oneliner:
perl -nae 'undef %saw ; next if $. == 1; shift @F; next if grep { $_ < 50 or $saw{$_}++ } @F; print ' input.txt
This basically translates to:
#!/usr/bin/env perl
use strict;
while (<>) {
my @F = split(' '); # split the current line
my %seen;
next if $. == 1; # skip the heading
shift @F; # ignore first element
next if grep { $_ < 50 or $seen{$_}++ } @F; # ignore lines with
# duplicate entries and
# entries less than 50
print; # print current line
}
add a comment |
This might work for you (GNU sed):
sed '1d;/S+ (S+) .* 1/d;/S+ S+ (S+) .* 1/d;/S+ S+ S+ (S+) .* 1/d;/S+( (100|[56789][0-9]..)){4}/!d' file
wow impressive, care to explain?
– Ulrich Dangel
Aug 7 '12 at 20:04
add a comment |
awk '($2!=$3) &&($2!=$4) && ($2!=$5) && ($3!=$4) &&($3!=$5) &&($4!=$5) && ($2>50) && ($3>50) && ($4>50) && ($5>50) {print $0}' input.txt
New contributor
This answer would be improved with some explanation of what your code block does and how.
– Michael Homer
1 hour ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f44888%2fget-row-data-for-non-matching-column-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
A perl-oneliner:
perl -nae 'undef %saw ; next if $. == 1; shift @F; next if grep { $_ < 50 or $saw{$_}++ } @F; print ' input.txt
This basically translates to:
#!/usr/bin/env perl
use strict;
while (<>) {
my @F = split(' '); # split the current line
my %seen;
next if $. == 1; # skip the heading
shift @F; # ignore first element
next if grep { $_ < 50 or $seen{$_}++ } @F; # ignore lines with
# duplicate entries and
# entries less than 50
print; # print current line
}
add a comment |
A perl-oneliner:
perl -nae 'undef %saw ; next if $. == 1; shift @F; next if grep { $_ < 50 or $saw{$_}++ } @F; print ' input.txt
This basically translates to:
#!/usr/bin/env perl
use strict;
while (<>) {
my @F = split(' '); # split the current line
my %seen;
next if $. == 1; # skip the heading
shift @F; # ignore first element
next if grep { $_ < 50 or $seen{$_}++ } @F; # ignore lines with
# duplicate entries and
# entries less than 50
print; # print current line
}
add a comment |
A perl-oneliner:
perl -nae 'undef %saw ; next if $. == 1; shift @F; next if grep { $_ < 50 or $saw{$_}++ } @F; print ' input.txt
This basically translates to:
#!/usr/bin/env perl
use strict;
while (<>) {
my @F = split(' '); # split the current line
my %seen;
next if $. == 1; # skip the heading
shift @F; # ignore first element
next if grep { $_ < 50 or $seen{$_}++ } @F; # ignore lines with
# duplicate entries and
# entries less than 50
print; # print current line
}
A perl-oneliner:
perl -nae 'undef %saw ; next if $. == 1; shift @F; next if grep { $_ < 50 or $saw{$_}++ } @F; print ' input.txt
This basically translates to:
#!/usr/bin/env perl
use strict;
while (<>) {
my @F = split(' '); # split the current line
my %seen;
next if $. == 1; # skip the heading
shift @F; # ignore first element
next if grep { $_ < 50 or $seen{$_}++ } @F; # ignore lines with
# duplicate entries and
# entries less than 50
print; # print current line
}
answered Aug 6 '12 at 22:35
Ulrich DangelUlrich Dangel
20.6k25971
20.6k25971
add a comment |
add a comment |
This might work for you (GNU sed):
sed '1d;/S+ (S+) .* 1/d;/S+ S+ (S+) .* 1/d;/S+ S+ S+ (S+) .* 1/d;/S+( (100|[56789][0-9]..)){4}/!d' file
wow impressive, care to explain?
– Ulrich Dangel
Aug 7 '12 at 20:04
add a comment |
This might work for you (GNU sed):
sed '1d;/S+ (S+) .* 1/d;/S+ S+ (S+) .* 1/d;/S+ S+ S+ (S+) .* 1/d;/S+( (100|[56789][0-9]..)){4}/!d' file
wow impressive, care to explain?
– Ulrich Dangel
Aug 7 '12 at 20:04
add a comment |
This might work for you (GNU sed):
sed '1d;/S+ (S+) .* 1/d;/S+ S+ (S+) .* 1/d;/S+ S+ S+ (S+) .* 1/d;/S+( (100|[56789][0-9]..)){4}/!d' file
This might work for you (GNU sed):
sed '1d;/S+ (S+) .* 1/d;/S+ S+ (S+) .* 1/d;/S+ S+ S+ (S+) .* 1/d;/S+( (100|[56789][0-9]..)){4}/!d' file
edited Aug 7 '12 at 20:25
jw013
36.6k7101125
36.6k7101125
answered Aug 7 '12 at 19:59
potongpotong
23612
23612
wow impressive, care to explain?
– Ulrich Dangel
Aug 7 '12 at 20:04
add a comment |
wow impressive, care to explain?
– Ulrich Dangel
Aug 7 '12 at 20:04
wow impressive, care to explain?
– Ulrich Dangel
Aug 7 '12 at 20:04
wow impressive, care to explain?
– Ulrich Dangel
Aug 7 '12 at 20:04
add a comment |
awk '($2!=$3) &&($2!=$4) && ($2!=$5) && ($3!=$4) &&($3!=$5) &&($4!=$5) && ($2>50) && ($3>50) && ($4>50) && ($5>50) {print $0}' input.txt
New contributor
This answer would be improved with some explanation of what your code block does and how.
– Michael Homer
1 hour ago
add a comment |
awk '($2!=$3) &&($2!=$4) && ($2!=$5) && ($3!=$4) &&($3!=$5) &&($4!=$5) && ($2>50) && ($3>50) && ($4>50) && ($5>50) {print $0}' input.txt
New contributor
This answer would be improved with some explanation of what your code block does and how.
– Michael Homer
1 hour ago
add a comment |
awk '($2!=$3) &&($2!=$4) && ($2!=$5) && ($3!=$4) &&($3!=$5) &&($4!=$5) && ($2>50) && ($3>50) && ($4>50) && ($5>50) {print $0}' input.txt
New contributor
awk '($2!=$3) &&($2!=$4) && ($2!=$5) && ($3!=$4) &&($3!=$5) &&($4!=$5) && ($2>50) && ($3>50) && ($4>50) && ($5>50) {print $0}' input.txt
New contributor
edited 1 hour ago
Jeff Schaller
43.1k1159137
43.1k1159137
New contributor
answered 1 hour ago
Deepika Reddy BilluriDeepika Reddy Billuri
11
11
New contributor
New contributor
This answer would be improved with some explanation of what your code block does and how.
– Michael Homer
1 hour ago
add a comment |
This answer would be improved with some explanation of what your code block does and how.
– Michael Homer
1 hour ago
This answer would be improved with some explanation of what your code block does and how.
– Michael Homer
1 hour ago
This answer would be improved with some explanation of what your code block does and how.
– Michael Homer
1 hour ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f44888%2fget-row-data-for-non-matching-column-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown