I have 8 options which are mandatory to run the script. However I am unable to pass option values after the first argument. Could you please let me know what I am doing wrong here.
#!/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}"
Results
f = ./test_data/HBR_Rep1_ERCC-Mix2_Build37-ErccTranscripts-chr22.read1.fastq
r =
hrp =
g =
sp =
b =
rsem_path =
out_path =