shell 命令笔记

+ $PATH  
  分割 且有先后顺序
  变量赋值:
+ root 可以在某个目录下?
+ du -sh  #统计当前目录的大小,以直观方式展现
less -N 可以加入行号
zless -S zless -N
tree -L 1 显示第 1层目录
tree -d  只展示目录
wget -c 断点续传
top -c 查看任务是否在内存中运行
paste -d":" t1 t2|tr ':' '#' 
zless  /teach/project/1.rna/3.raw_fq_25000reads/SRR1039510_1_100000.rawfq.gz |paste - - - -|cut -f1,2|tr '\t' '\n'|tr '@' '>'|le # fastq 转为fasta
sort -k 3nr file 对文件的第3列按数字进行反向排序
uniq -c 显示每行连续出现的次数
find find /teach/ -name '*.gz' -size +200M   查找 gz结尾且大小大于200M的文件
cat seq.txt |tr [atgc] [tacg]  
cat test.txt|tr -s '\n'  删除连续的空行
bc \
  scale=2 \
  5/2.0 \   结果保留两位有效数字
PS1="\[\033]2;\h:\u \w\007\033[33;1m\]\u \033[35;1m\t\033[0m \[\033[36;1m\]\w\[\033[0m\]\n\[\e[32;1m\]$ \[\e[0m\]"
ctrl + z 在Linux中表示 暂停
nl /etc/passwd  nl 可以将行号往下传
grep -ie  忽略大小写
nl /etc/passwd|grep -ie 'Service' -e vip23|grep bin
nl /etc/passwd | grep 'root\|qmcui'
echo $PATH | sed 's/:/\n/g' | grep -C 1 '/sbin'   -C 相当于 -A and -B 前一行后一行都输出
echo 192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0|sed 's/Bcast.*$//g'  可以正则匹配
sed '1,2s/ok//'   第一二行执行s/ok//操作!
nl /etc/passwd | sed 's/false$/&! ! !/' | less -S 把匹配上的false 替换成false!!!
nl /etc/passwd | sed -n '4~4p' 每4行输出第4行  必须和 -n 连用
nl /etc/passwd | sed '2,5c No 2-5 number'    # 替换2-5行
nl /etc/passwd | sed -n '5,7p'    # 输出 5-7 行
cat /etc/passwd |awk  -F ':'  'BEGIN {print "name,shell"}  {print $1","$7} END {print "blue,/bin/nosh"}'  在第一行输出 name,shell ,紧接着输出 awk的内容,最后一行输出blue,/bin/nosh

awk 四句必学代码+内置符

echo 1 2 3 |awk '{ print "total pay for", $1, "is", $2 * $3 }'

echo $PATH|awk -F ':' '{print $1}'
echo $PATH|awk -v FS=":" '{print $1}'
cat /etc/passwd |awk  -F ':' -v OFS="\t" '{print $1,$7}'
cat /etc/passwd |awk  -F ':'  'BEGIN {print "name,shell"}  {print $1","$7} END {print "blue,/bin/nosh"}'

对第四列求和:
zless -S /teach/database/gtf/gencode.v29.annotation.gtf.gz |grep -v '^#'|head -n 5|awk '{sum=sum+$4}END{print sum}'

准确输入第100行:
zless -S  /teach/database/gtf/gencode.v29.annotation.gtf.gz|nl|awk 'NR==100{print $0}'

zless -S /teach/database/gtf/gencode.v29.annotation.gtf.gz |awk '$1=="chr1" && $3=="gene" && $4>10000 && $5<50000{print $14}'
zless -S /teach/database/gtf/gencode.v29.annotation.gtf.gz |awk '{if($1=="chr1" && $3=="gene" && $4>10000 && $5<50000)print $14}'
zless -S /teach/database/gtf/gencode.v29.annotation.gtf.gz |awk '{if(NR >98 && NR<100)print $14}'

软件安装

软件安装注意事项

生信软件多是基于Python2,所以需要用conda创建Python2环境
如果某个软件是集运python3 的,再搭建个小环境即可,每个小环境只需在使用前激活
sra-tools fastqc trim-galore star hisat2 bowtie2 subread htseq cutadapt multiqc samtools

好资料推荐

Linux命令行与shell脚本编程大全.第3版.pdf
vim:https://www.jianshu.com/p/8c150a68a277
通配符:https://www.jianshu.com/p/b7f8c97b2ba6
grep :https://www.jianshu.com/p/22a4324ddfdf
sed:https://www.jianshu.com/p/1a853a0315d5
awk:https://www.jianshu.com/p/b6aec932adcf

总结

你可能感兴趣的:(shell 命令笔记)