美文网首页
每日一shell-字符串分割-2020-05-14

每日一shell-字符串分割-2020-05-14

作者: 爬山小虎 | 来源:发表于2020-05-15 10:40 被阅读0次

    llinux查看样本为单端测序还是双端测序:

    # cat findfile.test.sh
    samples=$(for i in $(ls *_R1*.fastq.gz);do echo "${i%%_*}";done)
    
    for ID in $samples
    do
        if [ -f ${ID}*R2*fastq.gz ];then
            echo PE ${ID}*R1*fastq.gz ${ID}*R2*fastq.gz
        else
            echo SE ${ID}*R1*fastq.gz
        fi
    done
    

    分隔文件名称,去除扩展名,得到样本名称列表:

    sh findfile.test.sh | grep PE | awk '{print $2}' | awk '{split($0,a,"_");print a[1]}' > PE.files.txt
    sh findfile.test.sh | grep SE | awk '{print $2}' | awk '{split($0,a,"_");print a[1]}' > SE.files.txt
    

    相关文章

      网友评论

          本文标题:每日一shell-字符串分割-2020-05-14

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