问题描述
如果我们有一个输入:
<$p$p><$c$c>cpdID,cpd_number,Cell_assay_id,Cell_alt_assay_id,Cell_type_desc,Cell_Operator,Cell_result_value,Cell_unit_value,assay_id,alt_assay_id,type_desc,operator,result_value,unit_value,Ratio_operator,Ratio,log_ratio,Cell_experiment_date,experiment_date,Cell_discipline,discipline49,CPD-7788990,1212,2323,IC50 ,, 100,嗯,1334,1331,奇,, 10,嗯,, 10,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-7788990,8888,9999,IC50 ,, 200,嗯,1334,1331,奇,, 10,嗯,, 20,-3,12- / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-7788990,5555,6666,IC50,&GT; 150,嗯,1334,1331,奇,, 10,嗯,&GT; 15,-2,12 / 6/2006 0:00,2 / 16 / 2007 0:00,细胞,酶
49,CPD-6666666,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.3,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.2,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
我们很想把它作为排序:如果$ 2是相同的,他们应该是在一组。在同一$第2组,$ 17条应从最高排序到最小。
<$p$p><$c$c>cpdID,cpd_number,Cell_assay_id,Cell_alt_assay_id,Cell_type_desc,Cell_Operator,Cell_result_value,Cell_unit_value,assay_id,alt_assay_id,type_desc,operator,result_value,unit_value,Ratio_operator,Ratio,log_ratio,Cell_experiment_date,experiment_date,Cell_discipline,discipline49,CPD-7788990,1212,2323,IC50 ,, 100,嗯,1334,1331,奇,, 10,嗯,, 10,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-7788990,5555,6666,IC50,&GT; 150,嗯,1334,1331,奇,, 10,嗯,&GT; 15,-2,12 / 6/2006 0:00,2 / 16 / 2007 0:00,细胞,酶
49,CPD-7788990,8888,9999,IC50 ,, 200,嗯,1334,1331,奇,, 10,嗯,, 20,-3,12- / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-6666666,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.2,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.3,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
尝试与其他职位的咨询数字似乎没有解决的问题。
排序-nk2,17 --field分隔=','input.csv
请参阅$ 2 CPD-1111:$ 17被-1.1,-1,-1.2,-1.3命令。我们希望它是-1,-1.1,-1.2,-1.3。
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.1,12 / 6 / 2006年0:00,2 / 16/2007 0:00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.2,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-1111,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1.3,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-6666666,8888,9999,IC50 ,, 400,嗯,1334,1331,奇,, 10,嗯,, 40,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-7788990,1212,2323,IC50 ,, 100,嗯,1334,1331,奇,, 10,嗯,, 10,-1,12 / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
49,CPD-7788990,5555,6666,IC50,&GT; 150,嗯,1334,1331,奇,, 10,嗯,&GT; 15,-2,12 / 6/2006 0:00,2 / 16 / 2007 0:00,细胞,酶
49,CPD-7788990,8888,9999,IC50 ,, 200,嗯,1334,1331,奇,, 10,嗯,, 20,-3,12- / 6/2006 0:00,2 / 16/2007 0: 00,细胞,酶
cpdID,cpd_number,Cell_assay_id,Cell_alt_assay_id,Cell_type_desc,Cell_Operator,Cell_result_value,Cell_unit_value,assay_id,alt_assay_id,type_desc,operator,result_value,unit_value,Ratio_operator,Ratio,log_ratio,Cell_experiment_date,experiment_date,Cell_discipline,discipline
以下两不这样做的伎俩也。可能大家知道,如果任何大师可能对此有何评论?这可能是一个简单的人,但阻止我们了好一阵子。谢谢你。
排序-rnk2,17 --field分隔=','input.csv排序-rnk2.17 --field分隔=','input.csv
听起来像是你想要的是
排序-r -t,-k2,2 -k17,17 input.csv
If we have an input:
cpdID,cpd_number,Cell_assay_id,Cell_alt_assay_id,Cell_type_desc,Cell_Operator,Cell_result_value,Cell_unit_value,assay_id,alt_assay_id,type_desc,operator,result_value,unit_value,Ratio_operator,Ratio,log_ratio,Cell_experiment_date,experiment_date,Cell_discipline,discipline
49,cpd-7788990,1212,2323, IC50 ,,100,uM,1334,1331,Ki,,10,uM,,10,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-7788990,8888,9999, IC50 ,,200,uM,1334,1331,Ki,,10,uM,,20,-3,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-7788990,5555,6666, IC50 ,>,150,uM,1334,1331,Ki,,10,uM,>,15,-2,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-6666666,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.3,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.2,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
We would love to sort it as : if $2 are the same, they should be in a group. Within the same $2 group, $17 should be sorted from max to min.
cpdID,cpd_number,Cell_assay_id,Cell_alt_assay_id,Cell_type_desc,Cell_Operator,Cell_result_value,Cell_unit_value,assay_id,alt_assay_id,type_desc,operator,result_value,unit_value,Ratio_operator,Ratio,log_ratio,Cell_experiment_date,experiment_date,Cell_discipline,discipline
49,cpd-7788990,1212,2323, IC50 ,,100,uM,1334,1331,Ki,,10,uM,,10,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-7788990,5555,6666, IC50 ,>,150,uM,1334,1331,Ki,,10,uM,>,15,-2,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-7788990,8888,9999, IC50 ,,200,uM,1334,1331,Ki,,10,uM,,20,-3,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-6666666,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.2,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.3,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
Numbers of tries and consulting of other posts didn't seem to solve the question.
sort -nk2,17 --field-separator=',' input.csv
See $2 in cpd-1111: $17 is ordered by "-1.1, -1, -1.2, -1.3". We would like it to be -1, -1.1, -1.2, -1.3".
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.2,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-1111,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1.3,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-6666666,8888,9999, IC50 ,,400,uM,1334,1331,Ki,,10,uM,,40,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-7788990,1212,2323, IC50 ,,100,uM,1334,1331,Ki,,10,uM,,10,-1,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-7788990,5555,6666, IC50 ,>,150,uM,1334,1331,Ki,,10,uM,>,15,-2,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
49,cpd-7788990,8888,9999, IC50 ,,200,uM,1334,1331,Ki,,10,uM,,20,-3,12/6/2006 0:00,2/16/2007 0:00,Cell,Enzyme
cpdID,cpd_number,Cell_assay_id,Cell_alt_assay_id,Cell_type_desc,Cell_Operator,Cell_result_value,Cell_unit_value,assay_id,alt_assay_id,type_desc,operator,result_value,unit_value,Ratio_operator,Ratio,log_ratio,Cell_experiment_date,experiment_date,Cell_discipline,discipline
The following two don't do the trick as well. May we know if any guru might have any comment? It might be an easy one but stops us for quite a while. Thanks.
sort -rnk2,17 --field-separator=',' input.csv
sort -rnk2.17 --field-separator=',' input.csv
sounds like what you want is
sort -r -t"," -k2,2 -k17,17 input.csv
这篇关于Linux的排序2和$; $ 17的数值,排序列遥远的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!