我有8個選項,它們是運行腳本必需的。但是,我無法在第一個參數後傳遞選項值。你能不能讓我知道我在這裏做錯了什麼。getopts用於運行腳本的必需選項
#!/usr/bin/env bash
usage() { echo "Usage: $0 -f sample_R1.fastq -r sample_R2.fastq -hrp HISAT2_REFERENCE_PATH -g GTF_file -sp KNOWN_SPLICE_FILE -b BOWTIE2_REFERENCE.fasta -rsem_path RSEM_REFERENCE -out_path OUTPUT_PATH -h help" 1>&2; exit 1; }
while getopts ":f:r:hrp:g:s:b:rsem_path:out_path:h" opt; do
case "${opt}" in
f) f="$OPTARG"; shift ;; # sample_R1.fastq
r) r="$OPTARG"; shift ;; # sample_R2_fastq
hrp) hrp="$OPTARG"; shift ;; # HISAT2_REFERENCE_PATH
g) g="$OPTARG"; shift ;; # GTF_file
sp) sp="$OPTARG"; shift ;; # KNOWN_SPLICE_FILE
b) b="$OPTARG"; shift ;; # BOWTIE2_REFERENCE
rsem_path) rsem_path="$OPTARG"; shift ;; #RSEM Reference path
out_path) out_path="$OPTARG"; shift ;; #Results output path
h | *) usage ; exit;;
esac
done
echo "f = ${f}"
echo "r = ${r}"
echo "hrp = ${hrp}"
echo "g = ${g}"
echo "sp = ${sp}"
echo "b = ${b}"
echo "rsem_path = ${rsem_path}"
echo "out_path = ${out_path}"
結果
f = ./test_data/HBR_Rep1_ERCC-Mix2_Build37-ErccTranscripts-chr22.read1.fastq
r =
hrp =
g =
sp =
b =
rsem_path =
out_path =
@melpomene糟糕。我通過將「hrp」選項切換到大寫字母H來修復它。 –