Linux命令学习--需求版本

作者: 溪溪溪溪溪川 | 来源:发表于2021-03-17 22:33 被阅读0次

    当工作文件和需求过多时,需要各种命令配合使用:

    1.rm 删除不满足条件的文件
    rm -r !(data)   #删除不满足条件的文件,删除data以外的文件
    rm -rf !(file1|file2) #删除file1 和file2以外的文件
     ls | grep -v keep | xargs rm #删除keep文件之外的所有文件
    find ./test/ | grep -v keep | xargs rm #删除当前test文件夹中keep文件之外的所有文件
    
    2.显示当前目录的绝对路径
    ls `pwd`/file #显示file的绝对路径
    
    3.查看zip
    zipinfo file.zip
    
    4.删掉尾部两行
    head -n -2 a.txt 
    
    从第六行开始显示
    tail -n +6 a.txt 
    
    5.在文件首行加一行
    sed -e '1i 2add pdf'  filter.contig.coverage.result |less
    sed -n '1~2p' a.txt #提取奇数行
    sed -n '0~2p' a.txt  #提取偶数行 
    
    
    6.给指定人开权限
    setfacl -R -m u:账户名:rwx ./
    
    6.统计文件数量(参考地址现在不见了???哎):
    find . -maxdepth 1 -type d | while read dir; do count=$(find "$dir" -type f | wc -l); echo "$dir : $count"; done >file_stat
    -maxdepth 1    过滤目录的深度
    -type d   文件类型为目录
    -type f    文件类型为文件
    
    7.grep -v 排除多个输出结果:
    grep test somefile | grep -v -e error -e critical -e warning
    grep test somefile | grep -vE '(error|critical|warning)'
    grep test somefile | grep -vE 'error|critical|warning'
    
    8.grep 查找多个输出结果: egrep相当于grep -E。
    grep -E 'CDS|exon|gene'  test.gff3
    grep -v "CDS\|exon\|gene'  test.gff3
    
    9.递归替换文件名
    sed -i "s/zhangsan/lisi/g" `grep zhangsan -rl /modules`
    sed -i.bak 's/a/b/g' a.txt #sed 之后备份
    

    10.fa转单行

    les *fa|perl -e '{$/=">";<>;while (<>){chomp;($id,$seq)=split /\n/,$_,2;$seq=~s/\n//g;print ">$id\n$seq\n";}}' >fmt.fa
    
    

    https://blog.csdn.net/JHON07/article/details/79212539?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&dist_request_id=1329187.9004.16178469144716785&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control

    https://blog.csdn.net/web_go_run/article/details/46009723

    相关文章

      网友评论

        本文标题:Linux命令学习--需求版本

        本文链接:https://www.haomeiwen.com/subject/hpdycltx.html