提取具有值的行50 [英] Extraction of rows which have a value > 50
本文介绍了提取具有值的行50的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何选择那些具有
值的行来自 21 列 150 行的大型矩阵的 10 个值.例如
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 21
osa-miR159a 0 42 42
osa-miR396e 0 7 9
vun-miR156a 121 77 4
ppt-miR156a 12 7 4
gma-miR6300 118 2 0
bna-miR156a 0 114 48
gma-miR156k 0 46 1
osa-miR1882e 0 7 0
.
.
.
所需的输出是:-
miRNameIDs degradome AGO LKM......till 21
vun-miR156a 121 77 4
gma-miR6300 118 2 0
bna-miR156a 0 114 48
.
.
.
till 150 rows
推荐答案
使用 perl one-liner
Using a perl one-liner
perl -ane 'print if $. == 1 || grep {$_ > 50} @F[1..$#F]' file.txt
说明:
开关:
-a
:在空间上分割行并将它们加载到数组中@F
-n
:为每个行"创建一个while(<>){...}
循环;在您的输入文件中.-e
:告诉perl
在命令行上执行代码.
-a
: Splits the line on space and loads them in an array@F
-n
: Creates awhile(<>){...}
loop for each “line” in your input file.-e
: Tellsperl
to execute the code on command line.
代码:
- <代码>$.== 1:检查当前行是否为第 1 行.
grep {$_ >50} @F[1..$#F]
:查看数组中的每个条目,看它是否大于 50.||
:逻辑OR
运算符.如果上述任何条件为真,它就会打印该行.
$. == 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.||
: LogicalOR
operator. If any of our above stated condition is true, it prints the line.
这篇关于提取具有值的行50的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文