Linux 中sed命令實現從gff檔案中僅僅提取基因名稱

小鲨鱼2018發表於2024-05-03

001、

(base) [b20223040323@admin1 x_test]$ ls                                 ## 測試gff檔案
GCF_000001405.40_GRCh38.p14_genomic.fna.gz  GCF_000001405.40_GRCh38.p14_genomic.gff
(base) [b20223040323@admin1 x_test]$ grep -v "^#" GCF_000001405.40_GRCh38.p14_genomic.gff | awk -F "\t" '$3 == "gene"' | sed 's/\(.*\)\(gene=[^;]\+\)\(.*\)/\2/' | head      ## 僅僅提取基因名稱,並保留前10行
gene=MIR6859-1
gene=MIR1302-2HG
gene=MIR1302-2
gene=FAM138A
gene=OR4F5
gene=LOC124903816
gene=LOC124900384
gene=LOC729737
gene=LOC124903814
gene=MIR6859-2
(base) [b20223040323@admin1 x_test]$ grep -v "^#" GCF_000001405.40_GRCh38.p14_genomic.gff | awk -F "\t" '$3 == "gene"' | sed 's/\(.*\)\(gene=[^;]\+\)\(.*\)/\2/' | tail     ## 僅僅提取基因名稱,並保留後10行
gene=ND4
gene=TRNH
gene=TRNS2
gene=TRNL2
gene=ND5
gene=ND6
gene=TRNE
gene=CYTB
gene=TRNT
gene=TRNP

相關文章