shell 判断字符串/文件是否存在

str="this is a string"

[[ $str =~ "this" ]] && echo "$str contains this"

判断文件:

if [ -f $fq1 ]
then
fq2=`ls /home/input${RGID}/*_2.fq.gz`
else
fq1=`ls /home/input${RGID}/*_1.fastq.gz`
fq2=`ls /home/input${RGID}/*_2.fastq.gz`
fi

本文来自博客园,作者:BioinformaticsMaster,转载请注明原文链接:https://www.cnblogs.com/koujiaodahan/p/13636762.html

原文地址:https://www.cnblogs.com/koujiaodahan/p/13636762.html