Linux 中sed命令实现从gff文件中仅仅提取基因名称
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
。