Get row data for non-matching column values












2















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.










share|improve this question



























    2















    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.










    share|improve this question

























      2












      2








      2








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 6 '12 at 21:52









      jackjack

      1,203102329




      1,203102329






















          3 Answers
          3






          active

          oldest

          votes


















          3














          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
          }





          share|improve this answer































            2














            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





            share|improve this answer


























            • wow impressive, care to explain?

              – Ulrich Dangel
              Aug 7 '12 at 20:04



















            -1














            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 





            share|improve this answer










            New contributor




            Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















            • This answer would be improved with some explanation of what your code block does and how.

              – Michael Homer
              1 hour ago











            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            3














            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
            }





            share|improve this answer




























              3














              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
              }





              share|improve this answer


























                3












                3








                3







                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
                }





                share|improve this answer













                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
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 6 '12 at 22:35









                Ulrich DangelUlrich Dangel

                20.6k25971




                20.6k25971

























                    2














                    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





                    share|improve this answer


























                    • wow impressive, care to explain?

                      – Ulrich Dangel
                      Aug 7 '12 at 20:04
















                    2














                    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





                    share|improve this answer


























                    • wow impressive, care to explain?

                      – Ulrich Dangel
                      Aug 7 '12 at 20:04














                    2












                    2








                    2







                    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





                    share|improve this answer















                    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






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    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



















                    • 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











                    -1














                    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 





                    share|improve this answer










                    New contributor




                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.





















                    • This answer would be improved with some explanation of what your code block does and how.

                      – Michael Homer
                      1 hour ago
















                    -1














                    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 





                    share|improve this answer










                    New contributor




                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.





















                    • This answer would be improved with some explanation of what your code block does and how.

                      – Michael Homer
                      1 hour ago














                    -1












                    -1








                    -1







                    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 





                    share|improve this answer










                    New contributor




                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.










                    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 






                    share|improve this answer










                    New contributor




                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    share|improve this answer



                    share|improve this answer








                    edited 1 hour ago









                    Jeff Schaller

                    43.1k1159137




                    43.1k1159137






                    New contributor




                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    answered 1 hour ago









                    Deepika Reddy BilluriDeepika Reddy Billuri

                    11




                    11




                    New contributor




                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.





                    New contributor





                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    Deepika Reddy Billuri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.













                    • 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





                    This answer would be improved with some explanation of what your code block does and how.

                    – Michael Homer
                    1 hour ago


















                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    CARDNET

                    Boot-repair Failure: Unable to locate package grub-common:i386

                    濃尾地震