less,head/tail函数是生信技能树[生信爆款入门课程]linux部分Day12的讲到的重要知识点。为加深理解,现在做下练习巩固。
一、less命令介绍
image.png使用练习
1.进入家目录 查看文件
$ cd
Last10 11:45:28 ~
$ ls
1 file readme.txt wenjianjia1
catFile Music test1 wenjianjia{1:5}
Data mydir test2
Data.tar.gz mydircd wenjian3
Last10 11:45:29 ~
2.进入Data文件
$ cd Data/
Last10 11:47:22 ~/Data
$ ls
Data.tar.gz
example.fa
example.fq
example.gtf
Homo_sapiens.GRCh38.102.chromosome.Y.gff3.gz
readme.txt
Last10 11:47:26 ~/Data
3.显示行号
1 chr1 ENSEMBL UTR 1737 2090 . 1 + . gene_id "ENSG00000223972"; trans 1 cript_id "ENST00000456328"; gene_type "protein_c 1 oding"; gene_status "KNOWN"; gene_name "RP11-34P 1 13.1"; transcript_type "protein_coding"; transcr 1 ipt_status "KNOWN"; transcript_name "RP11-34P13. 1 1-201"; level 3; havana_gene "OTTHUMG00000000961 1 ";
2 chr1 ENSEMBL exon 1737 2090 . 2 + . gene_id "ENSG00000223972"; trans 2 cript_id "ENST00000456328"; gene_type "protein_c 2 oding"; gene_status "KNOWN"; gene_name "RP11-34P 2 13.1"; transcript_type "protein_coding"; transcr
4.单行显示
chr1 ENSEMBL UTR 1737 2090 . +
chr1 ENSEMBL exon 1737 2090 . +
chr1 ENSEMBL transcript 1737 4275 .
chr1 HAVANA gene 1737 4275 . +
chr1 HAVANA exon 1873 1920 . +
chr1 HAVANA transcript 1873 3533 .
chr1 HAVANA exon 2042 2090 . +
chr1 HAVANA exon 2476 2560 . +
chr1 ENSEMBL UTR 2476 2584 . +
chr1 ENSEMBL exon 2476 2584 . +
chr1 HAVANA exon 2838 2915 . +
chr1 HAVANA exon 3084 3237 . +
chr1 ENSEMBL UTR 3084 4021 . +
chr1 ENSEMBL exon 3084 4275 . +
chr1 HAVANA exon 3316 3533 . +
chr1 ENSEMBL start_codon 4022 4024 .
chr1 ENSEMBL CDS 4022 4249 . +
example.gtf
5.查看压缩文件
$ cd
Last10 11:52:28 ~
$ zless Data.tar.gz
image.png
二、head/tail命令简单介绍
1.head / tail:查看文件的前/后 n 行,默认10 行
$ head readme.txt
Welcome to Biotrainee() !
This is your personal account in our Cloud.
Have a fun with it.
Please feel free to contact with me( email @163.com )
(http://www.biotrainee.com/thread-1376-1-1.
Last10 10:55:51 ~
$ head -2 readme.txt
Welcome to Biotrainee() !
This is your personal account in our Cloud.
Last10 10:56:17 ~
$ head -3 readme.txt
Welcome to Biotrainee() !
This is your personal account in our Cloud.
Have a fun with it.
Last10 10:56:26 ~
$ tail -1 readme.txt
(http://www.biotrainee.com/thread-1376-1-1.
Last10 10:56:36 ~
$ tail -2 readme.txt
Please feel free to contact with me( email @163.com )
(http://www.biotrainee.com/thread-1376-1-1.
Last10 10:56:44 ~
2.结合管道
head常结合管道符用于控制输出行数
$ cat readme.txt | head -1
Welcome to Biotrainee() !
$ cat -n example.gtf | head -10
1 chr1 ENSEMBL UTR 1737 2090 . gene_id "ENSG00000223972"; transcript_id "ENST00000456328"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "protein_coding"; transcript_status "KNOWN"; transcript_name "RP11-34P13.1-201"; level 3; havana_gene "OTTHUMG00000000961";
2 chr1 ENSEMBL exon 1737 2090 . gene_id "ENSG00000223972"; transcript_id "ENST00000456328"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "protein_coding"; transcript_status "KNOWN"; transcript_name "RP11-34P13.1-201"; level 3; havana_gene "OTTHUMG00000000961";
3 chr1 ENSEMBL transcript 1737 4275 gene_id "ENSG00000223972"; transcript_id "ENST00000456328"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "protein_coding"; transcript_status "KNOWN"; transcript_name "RP11-34P13.1-201"; level 3; havana_gene "OTTHUMG00000000961";
4 chr1 HAVANA gene 1737 4275 . gene_id "ENSG00000223972"; transcript_id "ENSG00000223972"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "protein_coding"; transcript_status "KNOWN"; transcript_name "RP11-34P13.1"; level 2; havana_gene "OTTHUMG00000000961";
5 chr1 HAVANA exon 1873 1920 . gene_id "ENSG00000223972"; transcript_id "ENST00000450305"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "unprocessed_pseudogene"; transcript_status "KNOWN"; transcript_name "RP11-34P13-001"; level 2; havana_gene "OTTHUMG00000000961"; havana_transcript "OTTHUMT00000002844"; ont "PGO:0000005";
6 chr1 HAVANA transcript 1873 3533 gene_id "ENSG00000223972"; transcript_id "ENST00000450305"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "unprocessed_pseudogene"; transcript_status "KNOWN"; transcript_name "RP11-34P13-001"; level 2; havana_gene "OTTHUMG00000000961"; havana_transcript "OTTHUMT00000002844"; ont "PGO:0000005";
7 chr1 HAVANA exon 2042 2090 . gene_id "ENSG00000223972"; transcript_id "ENST00000450305"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "unprocessed_pseudogene"; transcript_status "KNOWN"; transcript_name "RP11-34P13-001"; level 2; havana_gene "OTTHUMG00000000961"; havana_transcript "OTTHUMT00000002844"; ont "PGO:0000005";
8 chr1 HAVANA exon 2476 2560 . gene_id "ENSG00000223972"; transcript_id "ENST00000450305"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "unprocessed_pseudogene"; transcript_status "KNOWN"; transcript_name "RP11-34P13-001"; level 2; havana_gene "OTTHUMG00000000961"; havana_transcript "OTTHUMT00000002844"; ont "PGO:0000005";
9 chr1 ENSEMBL UTR 2476 2584 . gene_id "ENSG00000223972"; transcript_id "ENST00000456328"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "protein_coding"; transcript_status "KNOWN"; transcript_name "RP11-34P13.1-201"; level 3; havana_gene "OTTHUMG00000000961";
10 chr1 ENSEMBL exon 2476 2584 . gene_id "ENSG00000223972"; transcript_id "ENST00000456328"; gene_type "protein_coding"; gene_status "KNOWN"; gene_name "RP11-34P13.1"; transcript_type "protein_coding"; transcript_status "KNOWN"; transcript_name "RP11-34P13.1-201"; level 3; havana_gene "OTTHUMG00000000961";
Last10 11:11:25 ~/Data
网友评论