Linux系统介绍 文本查看、操作、统计命令(head/tail cat/tac less/more • wc sort uniq • cut paste)

文本查看、操作、统计命令
•head/tail cat/tac less/more
•wc sort uniq
•cut paste

cat

cat readme.txt

cat > file

cat file

zcat Homo_sapiens.GRCh38.102.chromosome.Y.gff3.gz|head

cat example.gtf|head

head example.gtf

head -n 2 example.gtf

head -2 example.gtf

 
 

less

less example.gtf

less -S  example.gtf

less -SN example.gtf

zless
zless -SN Homo_sapiens.GRCh38.102.chromosome.Y.gff3.gz

练习6
1. 用 cat 命令新建一个文本文件,并查看打印到屏幕
2. 用 head/tail 命令查看 example.fq 的 前 后 12 行
3. 用 less 命令查看 example. gtf 或 Y 染色体 gff 文件
探索 S 、 N 参数

2. 用 head/tail 命令查看 example.fq 的 前 后 12 行 

cat > catFile
cat catFile
pwd
ls

head example.fq

cat example.fq|head

cat example.fq|head -12

head -12 example.fq

 

 

 3. 用 less 命令查看 example. gtf 或 Y 染色体 gff 文件

 less -SN example.gtf

zless -SN

zless -SN Homo_sapiens.GRCh38.102.chromosome.Y.gff3.gz

cat > catFile

cat catFile

head -n 12 example.fq
tail -n 12 example.fq

less example.fq
less -S  example.fq
less -N  example.fq
less -SN example.fq

cat > filelyx

cat filelyx

cat example.fq| head

cat example.fq|head -12

head 12 example.fq
tail 12 example.fq

tail -12 example.fq

ls

wc -l example.fq

cat   example.fq|wc -l

zcat

zcat Homo_sapiens.GRCh38.102.chromosome.Y.gff3.gz|cut -f 1

zcat Homo_sapiens.GRCh38.102.chromosome.Y.gff3.gz|cut -f 1,4-7,9|less -SN

 

cat

cat example.gtf|head

cat example.gtf|cut -f 4|head

cat example.gtf|cut -f 4|sort

cat example.gtf|cut -f 4|sort -n                      正向

cat example.gtf|cut -f 4|sort -n -r                   逆向

cat example.gtf|cut -f 1|sort -n -r 

n v 不相容,不能同时 使用

cat example.gtf|cut -f 1|sort -n -r  -v

cat example.gtf|cut -f 1|sort -v

cat example.gtf|head

cat example.gtf|sort -k 4  -n|less -SN

ls

cat example.gtf|cut -f 3|head

cat example.gtf|cut -f 3|head -20

cat example.gtf|cut -f 3|head -20|uniq

cat example.gtf|cut -f 3|head -20|uniq -c

cat example.gtf|cut -f 3|head -20|sort|uniq 

cat example.gtf|cut -f 3|head -20|sort|uniq -c

文件拼接

cat >file1

cat >file2

cat file1 file2 > file3

cat file*


cat file3

paste 黏合

cat >fil4

paste fil4 readme.txt

paste fil4 readme.txt>file5

cat -a file

cat -a file5

seq 20

seq 20|paste - -

seq 20|paste - - - -

cat readme.txt

cat readme.txt|tr a-z A-Z

cat example.gtf|cut -f 3,4,5|head

cat example.gtf|cut -f 3,4,5|head|tr '\t'  ';'

练习7
1. 用 less 查看 example.gtf ,然后管道符传递给 wc
2. 截取 example.gtf 第 9 列的内容
3. 在第 2 步的基础上截取分号分割的第 1 列
4. 在第 3 步的基础上排序、去重复并统计
5. 在第 4 步的基础上,将空格替换成制表符


cat example.gtf|wc -l

cat example.gtf|cut -f 9

cat example.gtf|cut -f 9|head -1

 

3. 在第 2 步的基础上截取分号分割的第 1 列

cat example.gtf|cut -f 9|cut -d  ';' -f 1| head

4. 在第 3 步的基础上排序、去重复并统计

cat example.gtf|cut -f 9|cut -d  ';' -f 1| sort|uniq|wc -l

cat example.gtf|cut -f 9|cut -d  ';' -f 1| sort|uniq -c

 5. 在第 4 步的基础上,将空格替换成制表符

cat example.gtf|cut -f 9|cut -d  ';' -f 1| sort|uniq -c| tr ' ' ';'

cat example.gtf|cut -f 9|cut -d  ';' -f 1| sort|uniq -c| tr -s  ' ' ';'

cat example.gtf|cut -f 9|cut -d  ';' -f 1| sort|uniq -c| tr -s  ' ' ':'

cat /root/Data

cat example.gtf|wc

cat example.gtf|cut -f 9

cut -f 9 example.gtf|cut -f 1·-d  ';'|sort -V|uniq -c

cat example.gtf|cut -f 9|cut -d ';' -f 1|sort -V|uniq -c

less -SN example.gtf|cut -f 9|cut -d ';' -f 1|sort -n|uniq -c

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wangchuang2017

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值