首页 热点资讯 义务教育 高等教育 出国留学 考研考公
您的当前位置:首页正文

Linux里,如何使用awk进行提取

2024-12-18 来源:化拓教育网

实例一: 如何用awk 来进行row的filter。

dhcp-129-94:Desktop ye.liu$ awk '{if ($6=="+"){print}}' RefSeq_Genes.dms |head
chr1    201283451   201332993   NM_000299   0   +   201283702   201328836   0   15  453,104,395,145,208,178,63,115,156,177,154,187,85,107,2920, 0,10490,29714,33101,34120,35166,36364,36815,38526,39561,40976,41489,42302,45310,46622,
chr1    201283451   201332993   NM_001005337    0   +   201283702   201328836   0   14  453,104,395,145,208,178,115,156,177,154,187,85,107,2920,    0,10490,29714,33101,34120,35166,36815,38526,39561,40976,41489,42302,45310,46622,
chr1    117367432   117528870   NM_006699   0   +   117368183   117522957   0   13  1053,256,97,119,81,95,124,94,116,220,173,116,6046,  0,34753,38116,47280,53136,74798,93056,98901,125714,129330,131949,135422,155392,
chr1    167721949   167791919   NM_001146191    0   +   167722151   167787921   0   3   293,167,4100,   0,43633,65870,
chr1    150982022   150995638   NM_003568   0   +   150983105   150995322   0   14  357,97,91,97,95,114,91,80,60,85,96,59,123,379,  0,464,1067,1315,1952,2258,2563,4313,4579,5849,6068,6260,12554,13237,
chr1    167721949   167791919   NM_003953   0   +   167722151   167787921   0   6   293,167,214,133,103,4100,   0,43633,50325,51286,54114,65870,
chr1    167721949   167791919   NM_024569   0   +   167722151   167787844   0   5   293,167,214,133,4100,   0,43633,50325,51286,65870,
chr1    184387015   184629021   NM_030806   0   +   184477509   184619556   0   6   353,218,95,77,61,9504,  0,90370,120572,203723,211385,232502,
chr1    243256004   243500092   NM_001350247    0   +   243308151   243499785   0   19  236,153,86,114,126,129,65,97,189,139,153,135,117,143,128,109,132,127,337,   0,14100,14973,18538,30267,37086,48708,51782,51984,60750,74535,85034,88210,122716,159697,161963,170422,233009,243751,
chr1    243256004   243500092   NM_001350249    0   +   243271051   243499785   0   18  236,166,86,114,126,129,65,189,139,153,135,117,143,128,109,132,127,337,  0,14087,14973,18538,30267,37086,48708,51984,60750,74535,85034,88210,122716,159697,161963,170422,233009,243751,

#根据strand的正负,把hg38的RefSeq文档分开了
dhcp-129-94:Desktop ye.liu$ awk '{if ($6=="+"){print}}' RefSeq_Genes.dms > F.RefSeq_Genes.dms
dhcp-129-94:Desktop ye.liu$ awk '{if ($6=="-"){print}}' RefSeq_Genes.dms > R.RefSeq_Genes.dms

实例二: 如何用awk来筛某几列。

tkx424:p8_c2 ye.liu$ awk '{for(i=8;i<=8;i++)print $i}' PST.DEG.coding.unique.tsv >./0.terminal/PST.DEG.coding.unique.gene.tsv | awk '{for(i=8;i<=8;i++)print $i}' PST.DEG.noncoding.unique.tsv > ./0.terminal/PST.DEG.noncoding.unique.gene.tsv 
tkx424:p8_c2 ye.liu$  awk '{for(i=8;i<=8;i++)print $i}' PxT.DEG.coding.unique.tsv > ./0.terminal/PxT.DEG.coding.unique.gene.tsv | awk '{for(i=8;i<=8;i++)print $i}' PxT.DEG.noncoding.unique.tsv > ./0.terminal/PxT.DEG.noncoding.unique.gene.tsv
tkx424:p8_c2 ye.liu$ awk '{for(i=8;i<=8;i++)print $i}' xST.DEG.coding.unique.tsv >./0.terminal/xST.DEG.coding.unique.gene.tsv | awk '{for(i=8;i<=8;i++)print $i}' xST.DEG.noncoding.unique.tsv > ./0.terminal/xST.DEG.noncoding.unique.gene.tsv 
tkx424:p8_c2 ye.liu$ awk '{for(i=8;i<=8;i++)print $i}' xxT.DEG.coding.unique.tsv >./0.terminal/xxT.DEG.coding.unique.gene.tsv | awk '{for(i=8;i<=8;i++)print $i}' xxT.DEG.noncoding.unique.tsv > ./0.terminal/xxT.DEG.noncoding.unique.gene.tsv 
tkx424:p8_c2 ye.liu$ 
显示全文