我有一個bash腳本,如果在運行腳本時提供特定的命令行標誌,我想打印出該消息。例如,這裏是我的bash腳本Shell選項「OPTIONNAME」對我的腳本無法正常工作
while getopts ":hi:l:1:2:U:O:s:p:5:3:qQm:M:I:X:" opt; do
case $opt in
i)
index_folder=$OPTARG # Input folder
;;
l)
lib_type=$OPTARG # Library type
;;
1)
left_reads+=("$OPTARG") # Left reads
;;
2)
right_reads=("$OPTARG") # Right reads
;;
U)
single_reads+=("$OPTARG") # single end reads
;;
O)
bam_out=$OPTARG # Samoutput file
;;
s)
sra_id=$OPTARG # SRA ID
;;
p)
num_threads=$OPTARG # Number of threads
;;
5)
five_trim=$OPTARG # 5' trim
;;
3)
three_trim=$OPTARG # 3' trim
;;
q)
quality_33=$OPTARG # Phred 33
;;
Q)
quality_64=$OPTARG # Phread 64
;;
m)
min_intl=$OPTARG # Minimum intron length
;;
M)
max_intl=$OPTARG # Maximum intron length
;;
t)
tra_as=$OPTARG # Report alignments tailored for transcript assemblers including StringTie
;;
c)
tra_cuff=$OPTARG # Report alignments tailored specifically for Cufflinks
;;
esac
done
if [ ! -z $left_reads ] && [ ! -z $right_reads ]; then
echo "original"
elif [ ! -z $left_reads ] && [ ! -z $right_reads ] && [ ! -o $quality_33 ];
then
echo "quality"
fi
而當我嘗試像這樣運行。它打印正確
sh test.sh -i index -l "F" -1 reads_1.fq -1 e_coli_1000_1.fq -2 reads_2.fq -2 e_coli_1000_2.fq -p 2 -O final_bam -5 10 -3 10 -m 20 -M 200
original
然而,當我嘗試包括一個額外的選項(相當於第二個條件 - 「質量」),它仍然打印第一輸出
sh Hisat2_align.sh -i index -l "F" -1 reads_1.fq -1 e_coli_1000_1.fq -2 reads_2.fq -2 e_coli_1000_2.fq -p 2 -O final_bam -5 10 -3 10 -m 20 -M 200 -q
original
我在做什麼錯這裏?
[MCVE] - 你的代碼是遠遠最小的,我什至不知道你在問什麼。 – melpomene