awk
awk '$4>1000' a.txt
##过滤第四列大于1000的,输出来这些行awk '$1>1000 && $2=="mRNA" {print $1,$2,$3}' a.txt
#过滤第一列大于1000,第二列等于mRNA,输出只带第一列,第二列,第三列的所有行awk '$2~/^scaffold/' a.txt
#输出第二列开头匹配scaffold的行
grep
!warning: grep -c
can only count the number of times a string appears in each linegrep -o
can count the appears time of one string.
for example, we want know: How many times is the restriction site “ATGC” found in the chromosome 1?
the chromosome 1 like this:
1 | >chromosome 1 |
we can do that:less 1.fasta | perl -pe 's/\n//g' |grep -o "ATGC\|CGTA" |wc -l
#用空格替换掉所有的空格
orgrep -v ">" 1.fasta | tr -d "\n" |grep -o "ATGC\|GCAT" |wc -l
#用tr删掉所有的空格
the result is 4
cut
cut -f1 -d " " a.txt
#在不是以tab键隔开的文件中,用-d可以指定分隔符,如以空格隔开
统计一条fasta有多长
我的目录下有很多个fasta文件,我想看每一个fasta有多长:
1 | for f in */*fsa |
这样通常是不方便的,我们可以同时输出fasta的名字以及sequence的长度:
1 | for i in */*.fsa |
统计populus目录下有多少个文件
1 | for i in populus\* |