Extraction of rows which have a value > 50

前端 未结 1 1504
既然无缘
既然无缘 2021-01-07 15:09

How to select those lines which have a value < 10 value from a large matrix of 21 columns and 150 rows.eg.

miRNameIDs  degradome   AGO     LKM......till 2         


        
相关标签:
1条回答
  • 2021-01-07 15:27

    Using a perl one-liner

    perl -ane 'print if $. == 1 || grep {$_ > 50} @F[1..$#F]' file.txt
    

    Explanation:

    Switches:

    • -a: Splits the line on space and loads them in an array @F
    • -n: Creates a while(<>){...} loop for each “line” in your input file.
    • -e: Tells perl to execute the code on command line.

    Code:

    • $. == 1: Checks if the current line is line number 1.
    • grep {$_ > 50} @F[1..$#F]: Looks at each entries from the array to see if it is greater than 50.
    • ||: Logical OR operator. If any of our above stated condition is true, it prints the line.
    0 讨论(0)
提交回复
热议问题